Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

277
Views
Why does firebase.initializeApp not work?

I've basically copy and pasted the exact code from the firebase documentation on how to set up firestore. When I try to run my, app, I get a breaking error, which says my app has not been initialized.

here is my firebase.js config file:

import { initializeApp } from "firebase/app";
import { fbConfig } from "./secrets.js"
import { getFirestore } from "firebase/firestore";

const firebaseApp = initializeApp({
  apiKey: fbConfig.apiKey,
  authDomain: fbConfig.authDomain,
  projectId: fbConfig.projectId,
  storageBucket: fbConfig.storageBucket,
  messagingSenderId: fbConfig.messagingSenderId,
  appId: fbConfig.appId
});

console.log(firebaseApp)
export default getFirestore()

For comparison, here is a link to the firebase docs. My console log is returning this:

FirebaseAppImpl {_isDeleted: false, _options: {…}, _config: {…}, _name: '[DEFAULT]', _automaticDataCollectionEnabled: false, …}
{...}
[[Prototype]]: Object

Here is the code where firebase is being called, in a different file:

import { useState, useEffect } from "react";
import { useForm } from "react-hook-form";
import { doc, setDoc } from "firebase/firestore";
import db from "../firebase" 
//I'm expecting db to be my exported firestore call from firebase.js

function Admin() {
  const onFormSubmit = async (data) => {
    await setDoc(doc(db, "interviewees", data.name), {
      name: data.name,
      location: data.location,
      age: data.age,
    });
  };

  return(<a big component>)
}

When the Admin component renders, this error appears:

errors.ts:91 Uncaught FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).

so, it looks to my like there is an app being initialized. But my app crashing and the error message seems to disagree with my assessment. I'd appreciate any help!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Looks like I just had to delete my node modules and package log and npm install... 🙃

about 4 years ago · Juan Pablo Isaza Report

0

Try to return db not called function like export default getFirestore()

const firebaseApp = initializeApp({...});

const db = getFirestore() // In this line function are assigning database to a variable.

export { db }

Example of usage db:

import { addDoc, collection } from 'firebase/firestore'
import { db } from '...../firebase.js' // change path to your file

function addDocument(path, data) {
   addDoc(collection(db, path), data)
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!