here is the answer i wrote for this question
This is a problem I encountered, as well as updating to a new version of Firebase. You might want two separate firebase applications to be initialized, but I just wanted to use refs in two different places in my application, and I was getting the same error.
What you need to do for this situation is to create a firebase module for your application that only initializes firebase once, then you import or require it elsewhere in your application.
You need to copy the entire configuration object from the firebase console and paste it here using the API key and that's it.
Here is an example of how I created my module: modules / firebase.js
import firebase from 'firebase'; var firebaseConfig = { apiKey: "some-api-key", authDomain: "some-app.firebaseapp.com", databaseURL: "https://some-app.firebaseio.com", storageBucket: "some-app.appspot.com", }; var FbApp = firebase.initializeApp(firebaseConfig); module.exports = FbApp.database();
And then elsewhere in your application, you simply:
import Firebase from '/your/module/location' var messagesRef = Firebase.ref("messages/");
or
var Firebase = require('/your/module/location'); var messagesRef = Firebase.ref("messages/");
lommaj
source share