How to use the firebase/app.initializeApp 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 saltycrane / kage / lib / firebase.js View on Github external
/* @flow */
import firebase from "firebase/app";
import "firebase/auth";

try {
  firebase.initializeApp({
    apiKey: "AIzaSyDYXNe8SruSoEgaWWXyiIgZmGBm2xCleQ4",
    authDomain: "kage-e9d8c.firebaseapp.com",
    databaseURL: "https://kage-e9d8c.firebaseio.com",
  });
} catch (err) {
  // taken from https://github.com/now-examples/next-news/blob/master/lib/db.js
  if (!/already exists/.test(err.message)) {
    console.error("Firebase initialization error", err.stack);
  }
}

/**
 * Firebase auth functions. They return a promise.
 */
export function linkAnonymousUser(email: string, password: string) {
  const user = firebase.auth().currentUser;
github isamu / FriendlyEats-React / src / App.js View on Github external
import React, { useState, useEffect } from 'react';
import { Route, BrowserRouter as Router } from 'react-router-dom';
import CssBaseline from '@material-ui/core/CssBaseline';
import MuiThemeProvider from '@material-ui/core/styles/MuiThemeProvider';
import theme from './theme';
import Home from './Home';
import About from './About';
import ErrorModal from './ErrorModal';
import Restaurant from './Restaurant';
import * as firebase from "firebase/app";
import "firebase/firestore";
import "firebase/auth";
import config from './config';

try {
  firebase.initializeApp(config);
} catch (e) {
  // console.log(firebase init error)
}

function App() {
  const [errorModalOpen, setErrorModalOpen ] = useState(false);
  const [errorType, setErrorType ] = useState("");
  
  useEffect(()=>{
    const init = async () => {
      if (!config || Object.keys(config).length === 0) {
        setErrorType("app.config");
        setErrorModalOpen(true);
      } else {
        try {
          await firebase.auth().signInAnonymously();
github FirebaseExtended / firebase-auth-service-worker-sessions / src / script.js View on Github external
// Registration failed.
        console.log('Registration failed with ' + error.message);
      });
} else {
  window.location.assign('/unsupported');
}

/**
 * Initializes the app.
 */
const initApp = () => {
  // Renders sign-in page using FirebaseUI.
  ui.start('#firebaseui-container', getUiConfig());
};
// Initialize Firebase app.
var app = firebase.initializeApp(config);
// Set persistence to local.
firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL);
// Initialize the FirebaseUI Widget using Firebase.
const ui = new firebaseui.auth.AuthUI(app.auth());
// On page ready, initialize app.
window.addEventListener('load', initApp);
github prescottprue / generator-react-firebase / examples / react-firebase / src / containers / App / App.js View on Github external
import React from 'react'
import PropTypes from 'prop-types'
import { FirebaseAppProvider } from 'reactfire'
import { BrowserRouter as Router } from 'react-router-dom'
import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles'
import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/database'
import 'firebase/performance'
import ThemeSettings from 'theme'
import * as config from 'config'

const theme = createMuiTheme(ThemeSettings)

// Initialize Firebase instance
firebase.initializeApp(config.firebase)

function App({ routes }) {
  return (
    
      
        {routes}
      
    
  )
}

App.propTypes = {
  routes: PropTypes.object.isRequired
}

export default App
github davideast / table-tracer / src / index.tsx View on Github external
import * as path from 'path';
import * as functions from 'firebase-functions';
import * as firebase from 'firebase/app';
import 'firebase/firestore';

// Parse Args for debug setup
const args = {} 
process.argv.forEach(arg => args[arg] = arg);
const isDev = args['DEV'];
const port = args['PORT'] || 3000;

const router = express();

const indexHtmlPath = path.resolve(__dirname, 'index.html');
const indexHtml = fs.readFileSync(indexHtmlPath, 'utf8');
const firebaseApp = firebase.initializeApp({
  apiKey: "AIzaSyC1pXdWIiJZRcJUYtoIi-MmrRdnTcUISgk",
  authDomain: "ticket-fire.firebaseapp.com",
  databaseURL: "https://ticket-fire.firebaseio.com",
  projectId: "ticket-fire",
  storageBucket: "ticket-fire.appspot.com",
  messagingSenderId: "1090774042344"
});
const firestore = firebaseApp.firestore();
const settings = { timestampsInSnapshots: true };
firestore.settings(settings);
const col = firestore.collection('restaurants');

router.get('/', (req, res) => {
  col.get().then(snap => {
    const restaurants = snap.docs.map(d => ({ id: d.id, ...d.data() }));
    const html = render()
github tylermcginnis / re-base / tests / specs / firestore / listenToDoc.spec.js View on Github external
beforeAll(() => {
    testApp = firebase.initializeApp(firebaseConfig, 'DB_CHECK');
    collectionRef = testApp.firestore().collection(collectionPath);
    var mountNode = document.createElement('div');
    mountNode.setAttribute('id', 'mount');
    document.body.appendChild(mountNode);
  });
github WorldBrain / Memex / src / util / firebase-app-initialized.ts View on Github external
export const getFirebase = () => {
    if (!firebase.apps.length) {
        firebase.initializeApp(firebaseConfig)
    }
    return firebase
}
github gokulkrishh / anonymous-web / index.js View on Github external
import './style';
import { h } from 'preact';
import Home from './components/home';
import firebase from 'firebase/app';

const testEnv = {
  "apiKey": "AIzaSyB3X0VnbRACigiD1G1VcO0F8GFImzFIzdc",
  "authDomain": "test-anonymous-bcba0.firebaseapp.com",
  "databaseURL": "https://test-anonymous-bcba0.firebaseio.com",
  "projectId": "test-anonymous-bcba0",
  "storageBucket": ""
};

firebase.initializeApp(testEnv);

export default () => (
	<div id="root">
    
	</div>
);
github culee / restaurant / src / config / firebase.js View on Github external
import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/firestore';
import config from './firebaseConfig';

firebase.initializeApp(config);

export const authRef = firebase.auth();
export const GoogleAuthProvider = new firebase.auth.GoogleAuthProvider();
export const db = firebase.firestore();
github Zilliqa / nucleus-wallet / src / firebase.ts View on Github external
import firebase from 'firebase/app';

/*
  The apiKey essentially identifies your Firebase project. It is not a security risk for someone to know it.
  https://stackoverflow.com/questions/37482366/is-it-safe-to-expose-firebase-apikey-to-the-public
*/
const config = {
  apiKey: 'AIzaSyBTe5IC3O5U5Z93gyKk4Gd7MVOdrfdU1Ao',
  authDomain: 'nucleus-wallet.firebaseapp.com',
  databaseURL: 'https://nucleus-wallet.firebaseio.com',
  projectId: 'nucleus-wallet',
  storageBucket: 'nucleus-wallet.appspot.com',
  messagingSenderId: '290607547429'
};

firebase.initializeApp(config);