Project setup and initialization
Identify the Firebase project (client SDK)
The config object stores credentials to identify the Firebase project when interacting with Google servers. These credentials are not sensitive or confidential per se since they only serve to identify the project. They are exposed on the client.
const firebaseConfig = {
apiKey: "....",
authDomain: ".....firebaseapp.com",
projectId: "....",
storageBucket: ".....firebasestorage.app",
messagingSenderId: "....",
appId: "....",
}
initialize the app and embed the configuration in a helper object
We initialize a client SDK with a given config. It returns a helper object that we initialize other services with.
const app = initializeApp(firebaseConfig)
When working with several Firebase projects, we initialize client SDKs with different configs. Additional client SDKs require an internal string identifier that may be any string. The first client has a "[DEFAULT]" internal string identifier.
const app1 = initializeApp(firebaseConfig1)
const app2 = initializeApp(firebaseConfig2, "two")
initialize the admin SDK
In Cloud Functions, the admin SDK is automatically configured. We get the app helper with no config:
const app = initializeApp()