Accepted answer

If you are using the Modular SDK v9.0.0 then try refactoring your code like this:

import { initializeApp } from "firebase/app"
import { getAuth, onAuthStateChanged } from "firebase/auth"

const app = initializeApp(app)
const auth = getAuth(app)

const authListener = () => {
  onAuthStateChanged(auth, (user) => {
    if (user) {

If you want to use the older namespaced syntax (firebase.auth()) then change your imports to compat version:

import firebase from "firebase/comapt/app"
import "firebase/compat/auth"

You can read more about upgrading to modular SDK in the documentation.

Related Query

More Query from same tag