No Login Data Private Local Save

Shared Worker Demo - Online Cross‑Tab State

7
0
0
0

Shared Worker Demo

Experience real‑time cross‑tab communication and state sharing using the Shared Web Worker API.

Your browser does not support Shared Workers. Please use a modern browser like Chrome or Edge.
Tab 1 (Alice) disconnected
Shared Counter: 0
No messages yet
Tab 2 (Bob) disconnected
Shared Counter: 0
No messages yet

Frequently Asked Questions

A Shared Worker is a type of Web Worker that can be accessed by multiple browsing contexts (tabs, windows, iframes) from the same origin. Unlike a Dedicated Worker, which only serves one page, a Shared Worker allows real‑time communication and state sharing across different tabs.

Both enable communication between same‑origin contexts. The Broadcast Channel API is simpler and doesn’t require a separate script file. A Shared Worker gives you a central “process” where you can hold shared state and perform computation, making it more powerful for complex scenarios.

  • Real‑time synchronization of app state between multiple open tabs (e.g., a collaborative whiteboard).
  • Shared WebSocket connections to avoid duplicate server connections when the same user opens several tabs.
  • Centralized caching and data fetching for progressive web apps.
  • Multi‑tab logging or monitoring dashboards.

Yes! Because the Shared Worker is registered once per origin, you can open this page in two separate tabs and they will share counter state and exchange messages exactly like the two panels shown here.

Shared Workers are supported in all modern browsers except Safari on some iOS versions (where they may be partially supported or require flags). Always check Can I Use for the latest status. The API requires the worker script to be served from the same origin.