Persistence support for Firestore in Expo React Native app

Viewed 852

I am getting the below error:

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'm using the below imports

import "expo-firestore-offline-persistence";
import firebase from "firebase";
import "firebase/firestore";

Since Expo managed workflow does not support persistence, I'm using expo-firestore-offline-persistence package that I found.

How do I get the non-memory-only build of Firestore?

1 Answers

Memory-only Firestore was added in Version 7.13.0: March 26, 2020:

Added a memory-only firestore build. Instead of persisting data in the IndexedDB, it keeps it in memory. This build is about 14% smaller than the full featured build because it doesn't have IndexedDB related code. If you don't care about persisting data across sessions, or your code runs in environments that don't support IndexedDB, use this build to reduce your application size. It is available under a special import path. You can import it this way:

import * as firebase from 'firebase/app';
import 'firebase/firestore/memory';


// Don't change the format for any other products.
import 'firebase/auth';
// etc.

Or if using the CDN:

<script src="https://www.gstatic.com/firebasejs/7.13.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.13.0/firebase-firestore.memory.js"></script>
<!-- Don't change the format for any other products. -->
<script src="https://www.gstatic.com/firebasejs/7.13.0/firebase-auth.js"></script>
<!-- etc. -->
Related