Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

278
Vistas
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 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda