Skip to content
Advertisement

How to enable multi-tab synchronization for Firebase Web Version 9 (modular)?

I am using Firebase JavaScript Modular Web Version 9 SDK.

And I have enabled offline persistence as per these docs using this: enableIndexedDbPersistence(db).

Now I want to keep data synced between multiple open browser tabs.

I thought I could do that in the PersistenceSettings object like this: enableIndexedDbPersistence(db, { synchronizeTabs: true }).

But it turns out that synchronizeTabs property does not exist on the PersistenceSettings object.

The docs for the PersistenceSettings object do not have the synchronizeTabs property listed, but they do have a forceOwnership property with a description that mentions:

This cannot be used with multi-tab synchronization

This leads me to believe that multi-tab synchronization is possible. Because it is telling me that multi-tab synchronization cannot be used together with forceOwnership. I do not care about forceOwnership but I still want multi-tab synchronization.

So how do I enable multi-tab synchronization for the JavaScript Web Version 9 SDK?

Advertisement

Answer

You can directly use enablemultitabindexeddbpersistence to achieve what you want, instead of passing the PersistenceSettings object.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement