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 > / > clearIndexedDbPersistence

clearIndexedDbPersistence() function

Clears the persistent storage. This includes pending writes and cached documents.

Must be called while the Firestore instance is not started (after the app is terminated or when the app is first initialized). On startup, this function must be called before other functions (other than initializeFirestore() or getFirestore())). If the Firestore instance is still running, the promise will be rejected with the error code of failed-precondition.

Note: clearIndexedDbPersistence() is primarily intended to help write reliable tests that use Cloud Firestore. It uses an efficient mechanism for dropping existing data but does not attempt to securely overwrite or otherwise make cached data unrecoverable. For applications that are sensitive to the disclosure of cached data in between user sessions, we strongly recommend not enabling persistence at all.

Signature:

export declare function clearIndexedDbPersistence(firestore: FirebaseFirestore): Promise<void>;

Parameters

Parameter Type Description
firestore FirebaseFirestore The Firestore instance to clear persistence for.

Returns:

Promise<void>

A promise that is resolved when the persistent storage is cleared. Otherwise, the promise is rejected with an error.