Skip to main content
A modal overlay is host-owned: a view cannot mount one itself. useRequestModal lets the view ask the host to open it as a modal, pass data into it, and read whether the modal is currently showing.

Example

The carousel opens a product in a modal to confirm adding it to the cart, then runs the add when the shopper confirms.

Returns

useRequestModal returns the modal state plus an opener.

isOpen

true when the host is currently rendering the view in "modal" display mode. It tracks the modal lifecycle on its own: true after open, back to false when the modal closes.

params

The params the modal was opened with, surfaced back to the view while it is open. undefined when no modal is open, or when open was called without params.

open

Asks the host to render the view as a modal. Returns void: read the result from isOpen and params once the modal opens. options
ChatGPT opens a native host modal with the full RequestModalOptions. Other hosts polyfill it, rendering the modal inside the view’s iframe and honoring only params; title, template, and anchor are ignored.

Design for the Host

Adapt the view to display mode, theme, and device

useDisplayMode

Read and request the non-modal display modes

useRequestClose

Ask the host to dismiss the view