Syncing Multiple Browser Tabs Locally
You can use a BroadcastChannel if you want to keep browser tabs in sync. If you, for example, change some state in one tab, you might want to sync it with other tabs a user potentially has open.
You can now either fetch the current data from your backend if you reactivate a tab, or you keep it updated directly by using a BroadcastChannel, even saving your users some network bandwidth.
Let’s say you have a table with data and add a new entry. You want all browser tabs with the same page open to always stay in sync. In this case, your code could look similar to this: