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

280
Views
firebase.apps.length of undefined

Environment

  • Operating System version: Windows 11
  • Browser version: Chrome
  • Firebase SDK version: 9.0.2
  • Firebase Product: database

firebase.apps.length of undefined

Issue:

I dont know what happened today morning it opened my code and it shows something like app.firestore() is not a function and shows firebase.apps.length of undefined

Code:

 import * as firebase from 'firebase/app'
 import 'firebase/firestore'
 import 'firebase/auth'
 
const app = !firebase.apps.length ? firebase.initializeApp(firebaseConfig) : firebase.app()
 
const db = app.firestore()
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The syntax for Firebase has changed in v9, as everything is now modular/functional. You can now safely get an app with:

import { initializeApp } from 'firebase/app';
import { getFirestore, collection, getDocs } from 'firebase/firestore';

const app = initializeApp(firebaseConfig);
const db = getFirestore(app);

I highly recommend keeping Firebase's own documentation and this upgrade guide handy.


Alternatively, you can keep using the older syntax by using the compatibility mode of the newer SDKs, by importing from the compat path.

import firebase from 'firebase/compat/app';
import 'firebase/compat/firestore';

In that case the rest of your code stays unchanged.

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!