Skip to content

Instantly share code, notes, and snippets.

@prateekguptaiiitk
Created September 29, 2020 21:05
Show Gist options
  • Save prateekguptaiiitk/a6ba6288b8a6b7058ff310b7c71f6340 to your computer and use it in GitHub Desktop.
Save prateekguptaiiitk/a6ba6288b8a6b7058ff310b7c71f6340 to your computer and use it in GitHub Desktop.
Basic way to initialize firebase for web
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