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

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

0

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

about 4 years ago · Juan Pablo Isaza Report

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