Skip to content

Instantly share code, notes, and snippets.

@sambshapiro
Last active March 8, 2020 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sambshapiro/849a331934e75f169fafb80cf1292078 to your computer and use it in GitHub Desktop.
Save sambshapiro/849a331934e75f169fafb80cf1292078 to your computer and use it in GitHub Desktop.
Firebase Firestore & Cloud Functions Local Development with React
const firebase = require('firebase/app');
require('firebase/auth');
require('firebase/functions');
require('firebase/firestore');
const firebaseConfig = {
apiKey: '',
authDomain: '',
databaseURL: '',
projectId: '',
storageBucket: '',
messagingSenderId: '',
appId: '',
measurementId: '',
};
firebase.initializeApp(firebaseConfig);
if (window.location.hostname === 'localhost') {
console.log("testing locally -- hitting local functions and firestore emulators");
firebase.functions().useFunctionsEmulator('http://localhost:5001');
firebase.firestore().settings({
host: 'localhost:8080',
ssl: false
});
}
export const provider = new firebase.auth.GoogleAuthProvider();
export const auth = firebase.auth();
export const functions = firebase.functions();
export const db = firebase.firestore();
export const fieldval = firebase.firestore.FieldValue;
export default firebase;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment