How to use the firebase.app function in firebase

To help you get started, we’ve selected a few firebase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nicolasgarnier / friendlypix-web-react / microservices / renderTemplate.js View on Github external
function createFirebaseAppWithSignedInUser(uid = undefined, customToken) {
  // Instantiate a Firebase app.
  let firebaseApp;
  // Try to re-use cached firebase App.
  try {
    firebaseApp = firebase.app(/* uid */); // Uncomment. aka create named apps whe this bug is fixed: https://github.com/prescottprue/react-redux-firebase/issues/250
    console.log('Re-used a cached app for UID', uid);
  } catch(e) {
    firebaseApp = firebase.initializeApp(firebaseConfig/* , uid */); // Uncomment. aka create named apps when this bug is fixed: https://github.com/prescottprue/react-redux-firebase/issues/250
    console.log('Created a new Firebase App instance for UID', uid);
  }

  // Check if a Firebase user was signed in and a custom auth token was generated.
  let signInPromise;
  const firebaseAppUid = firebaseApp.auth().currentUser ? firebaseApp.auth().currentUser.uid : undefined;
  if (uid === firebaseAppUid) {
    signInPromise = Promise.resolve();
    console.log('Firebase App instance auth state is already correct.');
  } else if (uid && customToken) {
    console.log('Need to sign in user in Firebase App instance.');
    signInPromise = firebaseApp.auth().signInWithCustomToken(customToken).then(user => {
      console.log('User now signed-in! uid:', user.uid);
github davidroyer / nuxt-ssr-firebase-auth.v2 / firebase / app.js View on Github external
import env from 'config'

// uncomment the below if you use firestore DB instead of firebase DB
// require('firebase/firestore')

const config = {
  apiKey: env.FIREBASE.API_KEY,
  authDomain: `${env.FIREBASE.PROJECT_ID}.firebaseapp.com`,
  databaseURL: `https://${env.FIREBASE.DATABASE_NAME}.firebaseio.com`,
  projectId: env.FIREBASE.PROJECT_ID,
  storageBucket: `${env.FIREBASE.PROJECT_ID}.appspot.com`,
  messagingSenderId: env.FIREBASE.SENDER_ID
}
const googleProvider = new firebase.auth.GoogleAuthProvider()

export default !firebase.apps.length ? firebase.initializeApp(config) : firebase.app()
export {googleProvider}
github embiem / Better-Twitch-Chat / src / components / popup / Popup.js View on Github external
getFirebaseProjectId() {
    return firebase.app().options.authDomain.split('.')[0];
  }
github hoppula / refire / src / syncFirebase / createOptions.js View on Github external
return Object.keys(bindings).reduce((result, localBinding) => {
    const paramsState =
      typeof pathParams === "function" ? pathParams(state) : null

    const path =
      typeof bindings[localBinding].path === "function"
        ? bindings[localBinding].path(state, paramsState)
        : bindings[localBinding].path

    if (path) {
      const queryState =
        typeof bindings[localBinding].query === "function"
          ? bindings[localBinding].query(buildQueryState(), state).getState()
          : bindings[localBinding].query

      const firebaseRef = firebase
        .app(appName)
        .database()
        .ref(path)

      const query = bindings[localBinding].query
        ? bindings[localBinding].query(firebaseRef, state)
        : firebaseRef

      const type = bindings[localBinding].populate
        ? "Array"
        : bindings[localBinding].type

      result[localBinding] = {
        ...bindings[localBinding],
        path: path,
        query: query,
github material-foundation / material-remixer-js / src / lib / Remote.ts View on Github external
get remoteUrl(): string {
    let authDomain = firebase.app().options["authDomain"];
    return `https://${authDomain}/${this._remoteId}`;
  }
github hoppula / refire / src / actions / firebase.js View on Github external
return new Promise((resolve, reject) => {
      dispatch(updateProcessing("login", true))

      const { firebase: { name } } = getState()

      firebase
        .app(name)
        .auth()
        .signInWithEmailAndPassword(email, password)
        .then(() => {
          dispatch(updateProcessing("login", false))
          dispatch(updateCompleted("login", true))
          return resolve()
        })
        .catch(error => {
          dispatch(updateError("login", error.message))
          dispatch(updateProcessing("login", false))
          return reject()
        })
    })
  }