-
Notifications
You must be signed in to change notification settings - Fork 0
/
firebase.js
32 lines (29 loc) · 1.15 KB
/
firebase.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import "firebase/analytics" // If you need it
import firebase from "firebase/app"
import "firebase/auth" // If you need it
import "firebase/database"
import "firebase/firestore" // If you need it
import "firebase/performance" // If you need it
import "firebase/storage" // If you need it
const clientCredentials = {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_PUBLIC_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_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
measurementId: "G-XX8E71QSMB",
}
if (!firebase.apps.length) {
firebase.initializeApp(clientCredentials)
// Check that `window` is in scope for the analytics module!
if (typeof window !== "undefined") {
// Enable analytics. https://firebase.google.com/docs/analytics/get-started
if ("measurementId" in clientCredentials) {
firebase.analytics()
firebase.performance()
}
}
}
export default firebase