BroadcastChannel Playground

The warung’s app is open in three tabs, each holding a handy talky: one tab calls postMessage, so who hears it? Real BroadcastChannels, also to your other…

Why it matters

Syncing tabs is a real need: logging out everywhere, a cart that updates along, "you are logged in in another tab". People used the storage event of localStorage for it. BroadcastChannel is the clean API made for exactly that.

The key idea

A broadcast for the others, per object, after the script

Common mistakes

Try it in this playground