Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created August 4, 2021 07:43
Show Gist options
  • Save hieptl/0e876e967b1e1a12c01f0db69abc9494 to your computer and use it in GitHub Desktop.
Save hieptl/0e876e967b1e1a12c01f0db69abc9494 to your computer and use it in GitHub Desktop.
Initialize Firebase - Facebook Clone
import firebase from "firebase";
import "firebase/storage";
const firebaseConfig = {
apiKey: `${process.env.NEXT_PUBLIC_FIREBASE_API_KEY}`,
authDomain: `${process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN}`,
databaseURL: `${process.env.NEXT_PUBLIC_FIREBASE_DATABASE_URL}`,
projectId: `${process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID}`,
storageBucket: `${process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET}`,
messagingSenderId: `${process.env.NEXT_PUBLIC_FIREABSE_MESSAGING_SENDER_ID}`,
appId: `${process.env.NEXT_PUBLIC_FIREBASE_APP_ID}`,
};
const app = !firebase.apps.length
? firebase.initializeApp(firebaseConfig)
: firebase.app();
const realTimeDb = app.database();
const db = app.firestore();
const auth = app.auth();
const storage = firebase.storage();
export { auth, db, storage, realTimeDb };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment