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

164
Visualizações
Should I initialize Firebase on my web for every js file

Should i initialize my const firebaseConfig = {}; for every js file? on html

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

0

Nope, just once. If possible on the root js file

about 4 years ago · Juan Pablo Isaza Relatório

0

You haven't mentioned the type of project you are working on.

Here is how it is done in React project

  1. Create Firebase folder under src in React project
  2. Create config.js in Firebase folder

Initialize the app in config.js and export it

import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";

// Replace the following with your app's Firebase project configuration
const firebaseConfig = {
  apiKey: //your API key,
  authDomain: "random-project.com"
};

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

export {app, db}
 // some other file 
 import { db } from '../Firebase/config';
 const citiesCol = collection(db, 'cities');
 const citySnapshot = await getDocs(citiesCol);

You can read in more depth in official docs here:https://firebase.google.com/docs/web/setup

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