diff --git a/src/utils/firebaseConfig.js b/src/utils/firebaseConfig.js index 98f07d7..3ac43db 100644 --- a/src/utils/firebaseConfig.js +++ b/src/utils/firebaseConfig.js @@ -1,5 +1,12 @@ // Import the functions you need from the SDKs you need import { initializeApp } from 'firebase/app'; +import { getAuth } from 'firebase/auth'; +import { + CACHE_SIZE_UNLIMITED, + initializeFirestore, + persistentLocalCache, + persistentSingleTabManager, +} from 'firebase/firestore'; // TODO: Add SDKs for Firebase products that you want to use // https://firebase.google.com/docs/web/setup#available-libraries @@ -17,6 +24,13 @@ const firebaseConfig = { // Initialize Firebase const app = initializeApp(firebaseConfig); -const db = getFirestore(app); -export { db }; +// Enable IndexedDB persistence with single-tab manager +export const db = initializeFirestore(app, { + localCache: persistentLocalCache({ + tabManager: persistentSingleTabManager(), + cacheSizeBytes: CACHE_SIZE_UNLIMITED, + }), +}); + +export const auth = getAuth(app);