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

422
Views
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 answers
Answer question

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 Report

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 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!