Tabs Broadcast: JS Library

TabsBroadcast is a lightweight, easy-to-use JavaScript library that enables communication between multiple browser tabs.

TabsBroadcast is a lightweight, easy-to-use JavaScript library that enables communication between multiple browser tabs.

26 September 2024

About

TabsBroadcast is a lightweight, easy-to-use JavaScript library that enables communication between multiple browser tabs and is ideal for managing inter-tab communication via the BroadcastChannel API. It implements a singleton pattern to ensure a single instance and allows for registering, emitting, and handling various types of events across different browser tabs. Ideal for web applications that require synchronized data sharing, this package uses the BroadcastChannel API to efficiently exchange messages across open tabs, enhancing the user experience with real-time updates and seamless coordination.

Demo

You can see the demo

Tabs priority

The library also manages primary and slave tabs, ensuring that only one tab is designated as the primary tab, which can perform certain tasks exclusively. With a simple setup and minimal dependencies, tabs-broadcast offers developers a powerful tool for managing state and interactions across tabs in modern web apps.

Features

  • Singleton pattern to ensure a single instance.
  • Inter-tab communication using the BroadcastChannel API.
  • Primary-Slave tab management.
  • Event registration and handling.
  • Emit messages to all tabs or only from the primary tab.
  • Configurable settings.

To see more information on npmjs.com

License

This project is licensed under the MIT License. See the LICENSE file for details.