The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

Home > @firebase/firestore > / > enableIndexedDbPersistence

enableIndexedDbPersistence() function

Attempts to enable persistent storage, if possible.

Must be called before any other functions (other than initializeFirestore(), getFirestore() or clearIndexedDbPersistence().

If this fails, enableIndexedDbPersistence() will reject the promise it returns. Note that even after this failure, the Firestore instance will remain usable, however offline persistence will be disabled.

There are several reasons why this can fail, which can be identified by the code on the error.

* failed-precondition: The app is already open in another browser tab. * unimplemented: The browser is incompatible with the offline persistence implementation.

Signature:

export declare function enableIndexedDbPersistence(firestore: FirebaseFirestore, persistenceSettings?: PersistenceSettings): Promise<void>;

Parameters

Parameter Type Description
firestore FirebaseFirestore The Firestore instance to enable persistence for.
persistenceSettings PersistenceSettings Optional settings object to configure persistence.

Returns:

Promise<void>

A promise that represents successfully enabling persistent storage.