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

233
Visualizações
NextJS Firebase Authentication InitialiseApp error

I am having issues implementing firebase authentication with Google Provider in NextJS. I set up the environment variables and am successfully connecting to firebase. I am receiving the following error and cant seem to figure out a solution, TypeError: Cannot read properties of undefined (reading 'initializeApp'). Below is my code.

//firebaseApp.js
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
import { getDatabase } from "firebase/database";

const firebaseConfig = {//ENV Variables};

// Initialize Firebase
const app = initializeApp(firebaseConfig);

const db = getDatabase(app);

const auth = getAuth(app);
export { db, auth };

//firebaseAuthUI.config.js
import { GoogleAuthProvider } from "firebase/auth"

export const uiConfig = (firebase) => {
  return {
    signInFlow: "popup",
    signInSuccessUrl: "/",
    signInOptions: [GoogleAuthProvider.PROVIDER_ID],
  };
};

//login.js
import Head from 'next/head';
import { useRouter } from 'next/router';

import { useAuthState } from 'react-firebase-hooks/auth';
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
import { auth } from '../app/firebaseApp';
import { uiConfig } from '../config/firebaseAuthUI.config';

export default function Login() {
    const [user, loading, error] = useAuthState(auth);
    const router = useRouter();

    if (loading) return 'loading'
    else if (error) return error

    else if (user) {
        router.push('/');
    }

    const authConfig = uiConfig(auth);

    return (
        <>
            <Head>
                <title>Login</title>
            </Head>
            <StyledFirebaseAuth uiConfig={authConfig} firebaseAuth={auth} />
        </>
    )
}

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

0

Maybe you make mistake while creating env files? Maybe you forgot to add NEXT_PUBLIC to env files.

Next.js env files should be like this:

NEXT_PUBLIC_EXAMPLE=123
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