Offline PersistenceIntermediate
1Question 1 of 1
javascriptHow does Firestore offline persistence work on web and mobile devices?
Explanation & Concept
Firestore provides built-in offline data caching. When enabled, the SDK caches a local copy of documents that the application actively listens to or queries.
When the device loses connectivity, reads return data from the local cache and writes are queued locally. Once connection is restored, the SDK automatically synchronizes offline modifications with the server.
Code Example
javascript
import { initializeFirestore, persistentLocalCache, persistentMultipleTabManager } from "firebase/firestore";
import { app } from "./firebaseConfig";
// Enable multi-tab persistent IndexedDB cache on web
const db = initializeFirestore(app, {
localCache: persistentLocalCache({
tabManager: persistentMultipleTabManager()
})
});How It Works & Key Takeaways
Offline persistence delivers instant app load times and seamless offline user experiences without writing custom caching layers.
Mock Test · 1 Questions · Optional
Ready for Firestore Queries & Indexes?
Take a quick test to evaluate yourself, or move straight to the next module.
Intermediate1 questions