Parent window
Connecting…

Broadcast to all

BroadcastChannelwindowId
One-to-many
Same fan-out pattern as the postMessage demo. Each child opens with noopener and runs on its own event loop, so a stalled child never blocks the parent or the other children.
Children open0
Broadcasts sent0

Open several popups, arrange them so you can see all of them, and click Broadcast. Every child counter ticks up from the same call.

Code
One broadcast() on the parent, same handler on every child.
broadcast.tsx
// Parent
const iwpc = useIwpcWindow({ transport: 'broadcastChannel' });

for (let i = 0; i < 3; i++) {
  await iwpc?.open('./child', { width: 480, height: 460 });
}

// Same call, regardless of transport. `broadcast()` always travels
// over the same BroadcastChannel that powers `invoke()`'s routing.
iwpc?.broadcast('INCREMENT_COUNTER');

// Child
const iwpc = useIwpcWindow({ transport: 'broadcastChannel' });

useEffect(() => {
  iwpc?.register('INCREMENT_COUNTER', () => setCount((c) => c + 1));
  return () => iwpc?.unregister('INCREMENT_COUNTER');
}, [iwpc]);