Created
August 7, 2020 14:47
-
-
Save ivanfgm/dd08739d37cfcf222622d2e8d2087ef0 to your computer and use it in GitHub Desktop.
Config file to integrate firebase with next.js or react projects in general
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This assumes you have a .env.local with firebase config constants | |
import * as firebase from 'firebase/app' // yarn add firebase | |
import 'firebase/auth' // if you use them | |
import 'firebase/firestore' // if you use them | |
const config = { | |
apiKey: process.env.NEXT_PUBLIC_FIREBASE_APIKEY, | |
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTHDOMAIN, | |
databaseURL: process.env.NEXT_PUBLIC_FIREBASE_DATABASEURL, | |
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECTID, | |
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGEBUCKET, | |
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGINGSENDERID, | |
appId: process.env.NEXT_PUBLIC_FIREBASE_APPID, | |
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENTID | |
} | |
if (!firebase.apps.length) { | |
firebase.initializeApp(config) | |
} | |
export default firebase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment