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

382
Vistas
Import * as firebase from 'firebase/app' returns undefined

I'm trying to use firebase v9 on my Next.js project, but whenever I import it it seems to be returning undefined...

import * as firebase from 'firebase/app'

export function getFirebaseApp() {
  const clientCredentials = { ... }
  return firebase.initializeApp(clientCredentials)
}

However, when I try to run this in the browser, all I get is this error:

TypeError: Cannot read property 'initializeApp' of undefined

This happens with any variation of the import, I've tried several:

import * as firebase from 'firebase/app'
import firebase from 'firebase/app'
import { initializeApp } from 'firebase/app'

// and the same thing importing from '@firebase/app' instead, though don't think that'd ever work

I really have no idea what is going on, I don't think this is an issue from Next.js because even VSCode doesn't suggest importing anything from firebase, even though it's installed (I can see it in node_modules). I have this line in package.json:

{
  "dependencies": {
    "firebase": "^9.0.2"
  }
}

So this is a mistery really, I really have no idea what is going on. Any suggestions how I can fix this issue?

EDIT: Since I've gotten two comments suggesting this I guess I'll just put it here:

I am using the modular SDK, so I tried importing initializeApp directly, but it still did not work:

import { initializeApp } from 'firebase/app'

export function getFirebaseApp() {
  const clientCredentials = { ... }
  return initializeApp(clientCredentials)
}
TypeError: Cannot read properties of undefined (reading 'initializeApp')
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can install the next version of firebaseui and it will work with the new SDK:

npm i -S firebaseui@next

and integrate it in your app like here.

You don't have the benefits of the new SDK if you use the compat version.

As said in the github issues both libs won't update soon so it would pay off to do this little effort and move 100% to the new SDK.

about 4 years ago · Juan Pablo Isaza Denunciar

0

I found the source of the issue. I was using react-firebaseui - Unfortunately, it does not support the modular version of firebase (yet). So the solution is either to use something else, or use the compat library:

import firebase from 'firebase/compat/app'
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