frame-bridge
Examples

BroadcastChannel demo

Parent page and child iframe — connected via BroadcastChannel. The child runs in a real iframe (separate browsing context), same as across tabs.

The child panel is a real <iframe> at /iframe/broadcast-child. Send a ping from the parent and watch the response arrive in both logs and the DevTools below.

Parent

closed

Press "Send ping" to start

DevTools — parent bridge

DevTools

No bridge registered

How it works

Parent setup

<BridgeProvider<DemoMessage>
    open={true}
    channelName="frame-bridge-demo"
    role="parent"
    enabledTransports={["broadcast-channel"]}
>
    <ParentControls />
</BridgeProvider>

Child setup (iframe page)

// app/(embed)/iframe/broadcast-child/page.tsx
<BridgeProvider<DemoMessage>
    open={true}
    channelName="frame-bridge-demo"
    role="child"
    enabledTransports={["broadcast-channel"]}
>
    <ChildInner />
</BridgeProvider>

Message flow

parentbridge.send({ type: 'ping', value: 1 })
BroadcastChannel (cross browsing context)
child iframeonMessage receives { type: 'ping', value: 1 }
child iframereturns { type: 'pong', value: 2 }
parentawait resolves with { type: 'pong', value: 2 }