Iframe Demos
postMessage selection widgets
Iframe Selection Widgets
A cross-iframe selection pattern: the parent page opens a full-screen modal containing an iframe route. The user picks items, and the result is returned to the parent via window.postMessage. All payloads are validated with Zod and scoped by a per-session UUID.
Single Select
Pick exactly one entity from an iframe list. The iframe closes automatically after selection.
Hook:useSingleSelectIFrameOpen DemoMulti Select
Pick many entities with checkboxes. The iframe stays open until the user confirms, then sends the full selection back.
Hook:useMultiSelectIFrameOpen DemoMessage Protocol
Parent opens iframe with `?sessionId=<uuid>` appended to the URL.
Child attaches its `message` listener, then `useFrameChild` sends `{ kind: "I_AM_READY", sessionId }` to parent.
Parent optionally sends pre-selection payloads and always finishes hydration with `{ kind: "PARENT_SYNC_COMPLETE", sessionId, hasInitialData }`.
Child keeps a centered loading overlay on top of the iframe until parent sync is complete, even when the selection is empty.
User picks → child calls `sendBack({ uuid, data })` → parent receives validated payloads, then `CLOSE_MODAL`.