Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native: Firebase Error: No Firebase App [DEFAULT] has been created - call Firebase App.initializeApp() (app/no-app) [duplicate]

I am getting this error when I was trying to connect firebase with my React Native App.

Firebase Error: No Firebase App [DEFAULT] has been created - call Firebase App.initializeApp() (app/no-app)

I have added my code here-

    import { initializeApp } from "firebase/app";
    import { getAuth } from "firebase/auth";
    import { getFirestore } from "firebase/firestore";

   // Your web app's Firebase configuration
const RNfirebaseConfig = {
  apiKey: "........",
  authDomain: "note-app-rn.firebaseapp.com",
  projectId: "note-app-rn",
  storageBucket: "note-app-rn.appspot.com",
  messagingSenderId: ".....",
  appId: "......"
};

const app = initializeApp(RNfirebaseConfig);
export const auth = getAuth(app);
export const db = getFirestore(app);
like image 794
msadikjowel Avatar asked Mar 28 '26 11:03

msadikjowel


2 Answers

Did it happen during migration to new React Native architecture?

Remember to change your import:

  • from: @import Firebase; in AppDelegate.m
  • to: #import <Firebase.h> in AppDelegate.mm
like image 78
Daniel Danielecki Avatar answered Mar 31 '26 08:03

Daniel Danielecki


try this,

import firebase from '@react-native-firebase/app';
import '@react-native-firebase/auth';
import '@react-native-firebase/firestore';

const RNfirebaseConfig = {
  apiKey: "........",
  authDomain: "note-app-rn.firebaseapp.com",
  projectId: "note-app-rn",
  storageBucket: "note-app-rn.appspot.com",
  messagingSenderId: ".....",
  appId: "......"
};

let app;
if (firebase.apps.length === 0) {
    app = firebase.initializeApp(RNfirebaseConfig )
} else {
    app = firebase.app()
}

const db = firebase.firestore();
const auth = firebase.auth();
like image 44
Shivam Avatar answered Mar 31 '26 07:03

Shivam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!