...

/

Initializing Firebase

Initializing Firebase

In this lesson, we'll initialize Firebase using a separate class.

We'll cover the following...

Importing Firebase

Let’s import Firebase from the library we installed earlier, and then use it within a new Firebase class to initialize Firebase with the configuration we saw in the previous lesson:

Press + to interact
import app from 'firebase/app';
const config = {
apiKey: process.env.REACT_APP_API_KEY,
authDomain: process.env.REACT_APP_AUTH_DOMAIN,
databaseURL: process.env.REACT_APP_DATABASE_URL,
projectId: process.env.REACT_APP_PROJECT_ID,
storageBucket: process.env.REACT_APP_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_MESSAGING_SENDER_ID,
};
class Firebase {
constructor() {
app.initializeApp(config);
}
}
export default Firebase;

That’s all we really need for a Firebase configuration in our application.

Production vs. Environment

Optionally, ...