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

345
Views
firebase firestore offline persistence FirebaseError

I searched for several hours to implement firestore offline persistence because its crucial for my app to work. I handle multiple chats inside my app and its a fatal error to download data every time again.

This is my code sample, its the root App.js file which is the first one beeing called:

....
//imports related to firebase
import * as firebase from "firebase";
import ApiKeys from "./constants/ApiKeys";


export default function App() {
  //firebase project initialisation
  if (!firebase.apps.length) {
    firebase.initializeApp(ApiKeys);
    var db = firebase.firestore();
    db.settings({ experimentalForceLongPolling: true });
    console.log("DB INITIALISED");
    db.enablePersistence() //HERE IS THE PROBLEM
        .catch((err) => {
            if (err.code == 'failed-precondition') {
                // Multiple tabs open, persistence can only be enabled
                // in one tab at a a time.
                // ...
            } else if (err.code == 'unimplemented') {
                // The current browser does not support all of the
                // features required to enable persistence
                // ...
            }
      })
  };.....

The API Keys look like this:

const firebaseConfig = {
    apiKey: "***",
    authDomain: "***",
    databaseURL: "https://***",
    projectId: "***",
    storageBucket: "***",
    messagingSenderId: "***",
    appId: "***",
    measurementId: "***"
  };

  export default firebaseConfig;

I receive the following error which I can not work around:

FirebaseError: You are using the memory-only build of Firestore. Persistence support is only available via the @firebase/firestore bundle or the firebase-firestore.js build.

I have installed the complete "firebase" bundle and also access to @firebase/firestore, I checked this already, and I implemented it same as in the official docs. Everything works but when I want to enable the persistence... It crashes with the error mentioned above.

What can I do now? Do I miss another package, have I done something wrong?

As a sidenote, authentification persistence works perfectly inside my app, just the firestore persistence is failing.

Currently using firebase SDK 8.2.3

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

0

I have developed my app with Expo and was pointed to expo-firestore-offline-persistence. I notice on their page they talk about react-native-firebase for enabling persistence on RN - though that seems to require ejecting from Expo.

It seems this is an issue with polyfill on the RN platform. In other words, the Javascript that Firestore requires doesn't have everything necessary on the React Native platform - something that common browsers will have. So the "fix" is to leverage a component like react-native-firebase or expo-firestore-offline-persistence that give you that extra capability on native.

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!