aabroukh's picture
Add files using upload-large-folder tool
b136cbe verified
Raw History Blame Contribute Delete
1.37 kB
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
import { getFirestore } from "firebase/firestore";
// Configure your own Firebase project — see .env.example.
// Create-React-App injects any var prefixed with REACT_APP_ at build
// time, so these values land in the public JS bundle. That is fine for
// the Firebase web config (which is intended to be public); never put
// service-account / admin keys here.
const firebaseConfig = {
apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.REACT_APP_FIREBASE_APP_ID,
};
// True only when at least the apiKey + projectId are set. Otherwise we
// keep `auth` and `db` as null so the React app can render a friendly
// "Firebase not configured" screen instead of crashing at module load.
const firebaseConfigured = Boolean(
firebaseConfig.apiKey && firebaseConfig.projectId
);
let auth = null;
let db = null;
if (firebaseConfigured) {
const app = initializeApp(firebaseConfig);
auth = getAuth(app);
db = getFirestore(app);
}
export { auth, db, firebaseConfigured };