Created
September 29, 2020 21:05
-
-
Save prateekguptaiiitk/a6ba6288b8a6b7058ff310b7c71f6340 to your computer and use it in GitHub Desktop.
Basic way to initialize firebase for web
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
import firebase from "firebase/app"; | |
import "firebase/auth"; | |
import "firebase/firestore"; | |
import "firebase/functions"; | |
import "firebase/storage"; | |
import "firebase/messaging"; | |
import "firebase/performance"; | |
const config = { | |
// set your config here | |
}; | |
if (!firebase.apps.length) { | |
firebase.initializeApp(config); | |
} | |
const auth = firebase.auth(); | |
const storage = firebase.storage(); | |
const functions = firebase.functions(); | |
const firestore = firebase.firestore(); | |
let messaging = null; | |
try { | |
if (firebase.messaging.isSupported()) { | |
messaging = firebase.messaging(); | |
messaging.usePublicVapidKey("your publicVapidKey here"); | |
} | |
} catch (e) {} | |
const perf = firebase.performance(); | |
export { firebase, auth, storage, functions, firestore, messaging }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment