-
Notifications
You must be signed in to change notification settings - Fork 986
Description
Operating System
macOS Monterey 12.7.3
Environment (if applicable)
Chrome 127.0.6533.120
Firebase SDK Version
10.13.0
Firebase SDK Product(s)
Firestore
Project Tooling
React using Ionic Capacitor's default toolset
Detailed Problem Description
Creating an instance of a firebaseApp also creates instances of other services (such as analytics, firestore etc) - this means that you cannot specify config options for each service that has already been initalised.
Steps and code to reproduce issue
I create an instance of my app.
const firebaseConfig = {
apiKey: import.meta.env.VITE_FIREBASE_API_KEY,
authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN,
databaseURL: import.meta.env.VITE_FIREBASE_DATABASE_URL,
projectId: import.meta.env.VITE_FIREBASE_PROJECT_ID,
storageBucket: import.meta.env.VITE_FIREBASE_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_FIREBASE_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_FIREBASE_APP_ID,
measurementId: import.meta.env.VITE_FIREBASE_MEASUREMENT_ID,
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
// Get Firestore
const firestore = getFirestore(app);
This works fine but then if I want to specify certain settings for firestore, I have to add configuration details for this service.
// Specify firestore settings
const firestore = initializeFirestore(app, {localCache: memoryLocalCache()});
I can't do this because initializeFirestore() has already been called by initializeApp(), it just throws an error and I can't specify any settings.
I also can't specify individual instances for each service without creating an app instance (as they all take in the app instance as a parameter). I can't specify whether to create certain services or not because this option is not available when calling initializeApp().
Because of this there seems to be no way to specify any sort of configuration for firestore (or any other service created by initializeApp().