From 0918e1a5803af7711c894c0b63cfde5945acbc25 Mon Sep 17 00:00:00 2001 From: ZL Asica <40444637+ZL-Asica@users.noreply.github.com> Date: Sat, 26 Oct 2024 15:50:25 -0500 Subject: [PATCH] feat: export auth from firebase --- src/utils/firebaseConfig.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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);