Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

423
Visualizações
Next.js TypeError: (0 , firebase_auth__WEBPACK_IMPORTED_MODULE_1__.onAuthStateChanged) is not a function

Im new to Next.js development. Im following a Youtube tutorial to build a Whatsapp clone. Im using firebase8.9 as the database

I want to check if the user is logged in, then go to the home page else redirect to the login page.

import '../styles/globals.css'
import { useAuthState } from "react-firebase-hooks/auth"
import { auth, db } from "../firebase"
import Login from "./login"

function MyApp({ Component, pageProps }) {

  const [user] = useAuthState(auth);

  

  return <Component {...pageProps} />;
}

export default MyApp

my firebase.js file

import firebase from 'firebase';


const firebaseConfig = {
    apiKey: "apikey",
    authDomain: "authdomain",
    projectId: "projectid",
    storageBucket: "storagebucket",
    messagingSenderId: "messagingsenderid",
    appId: "appid"
  };


const app = !firebase.apps.length ? firebase.initializeApp(firebaseConfig) : firebase.app();

const db = app.firestore();

const auth = app.auth();

const provider = new firebase.auth.GoogleAuthProvider();

export { db, auth, provider };

Please help me to solve this problem. Thanks in advance!

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

As the time, firebase version is upgraded as of now to version 9+ as well as the firebase hooks changing the entire structure. So, what you simply need to do is go to your package.json file and change your "firebase" version to "firebase": "8.0.0".

Now look for "react-firebase-hooks" in the same package.json file and change its version to "react-firebase-hooks": "^3.0.4" from the current version.

Now, open up your terminal and run yarn install, this will solve the version issue.

about 4 years ago · Juan Pablo Isaza Relatório

0

Was stuck on the same error

Just go to the node modules and change the version of react-firebase-hook from 4.0.0 to 3.0.4.

And then a simple yarn install will solve the issue...

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda