@stateloom/tab-sync
v1.0.0-alpha.0
Published
Cross-tab state synchronization middleware via `BroadcastChannel`.
Readme
@stateloom/tab-sync
Cross-tab state synchronization middleware via BroadcastChannel.
Install
pnpm add @stateloom/tab-syncQuick Start
import { broadcast } from '@stateloom/tab-sync';
import { createStore } from '@stateloom/store';
const store = createStore(
(set) => ({
theme: 'light' as 'light' | 'dark',
toggle: () => set((s) => ({ theme: s.theme === 'light' ? 'dark' : 'light' })),
}),
{ middleware: [broadcast({ channel: 'theme-sync' })] },
);Exports
| Export | Description |
| -------------------- | ----------------------------------------------------------- |
| broadcast(options) | Create a cross-tab sync middleware using BroadcastChannel |
Documentation
Full documentation with API reference, conflict resolution, and multi-store patterns: docs/api/tab-sync
License
MIT
