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

215
Views
TypeError: Cannot read property 'length' of undefined - Firebase

I am trying to connect to Firebase.

Code from firebase.js:

import * as firebase from "firebase/compat/app";

const firebaseConfig = {
  apiKey: "***",
  authDomain: "***",
  projectId: "***",
  storageBucket: "***",
  messagingSenderId: "***",
  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 };

Error Message

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

As I said in my comment on your other thread, firebase imports have changed recently. Try to change fribase to firebase/compat/app Documentation

about 4 years ago · Juan Pablo Isaza Report

0

You're missing imports for Firestore (as the error mentions) and Authentication.

import * as firebase from "firebase/compat/app";
import 'firebase/compat/auth';
import 'firebase/compat/firestore';

Also see the documentation on updating imports to v9 compat.

about 4 years ago · Juan Pablo Isaza Report

0

Just coming across this, I hope this solution helps:
simply upgrade "firebase" to version: "^9.4.0"

import { initializeApp } from 'firebase/app';
import { getFirestore } from 'firebase/firestore';
import { getAuth, GoogleAuthProvider } from 'firebase/auth'

const firebaseConfig = {
apiKey: "*********************",
authDomain: "**************.com",
projectId: "*********",
storageBucket: "**************",
messagingSenderId: "***********",
appId: "**********************"
};

const app = initializeApp(firebaseConfig);

const db = getFirestore(app);//access to the database
const auth = getAuth(); //access to the authentication
const provider = new GoogleAuthProvider(); //access tp the provider

export { db, auth, provider };
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!