Log out in one tab and every tab logs out. Sync Zustand, Redux, signals or useState across open tabs, and new tabs start with the current state. No server, any framework.
Each frame below is its own page with its own store, like two browser tabs. Add to the cart, switch the theme or log out, and the other one follows. So do the tabs in the hero.
Your browser has no BroadcastChannel (needs Safari 15.4+ or any current browser), so the tabs can't talk. Nothing breaks, each one just keeps its own state.
Each change is one message. Tabs never send it back.
Open a real new tab ↗Waiting for a change…
The browser can already pass messages between tabs. What it doesn't do is plug into your store, stop the echo when a tab applies a change, or tell a tab that just opened what everyone else already knows.
Anything with get, set and subscribe. Zustand fits as is.
A new tab asks the open ones and starts with their state.
A tab never sends back a change it just received.
React hook included. Vue, Svelte, Angular, none.
State travels as JSON, so functions stay in each tab.
About 0.5 kB gzipped, typed, zero dependencies.
Every tab that syncs a store under the same name shares it. Call it once per store. It returns a function that stops syncing.
import { tabsync } from 'tab-sync-lite';
const stop = tabsync('cart', {
get: store.getState,
set: store.setState,
subscribe: store.subscribe,
});
Tabs of the same site (same origin) only. Nothing leaves the browser.
Wrap the state you already have. Stop syncing when it goes away.