Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Firebase work offline with React Native?

I have an existing iOS app that I'd like to start adding some React Native screens to. The app uses Firebase with persistence enabled so that it works offline. Is there a way to also use Firebase directly within React Native while maintaining offline functionality?

If the answer is "Yes", do iOS and React Native share the same local data store? This would be important, so that offline data changes on iOS screens would reflect data changes made from React Native screens and vice versa.

Thanks for sharing your insight on this!

like image 324
bgolson Avatar asked Feb 24 '16 04:02

bgolson


People also ask

Can I use Firebase without Internet?

By enabling persistence, any data that the Firebase Realtime Database client would sync while online persists to disk and is available offline, even when the user or operating system restarts the app. This means your app works as it would online by using the local data stored in the cache.

Does Firebase firestore work offline?

Stay organized with collections Save and categorize content based on your preferences. Cloud Firestore supports offline data persistence. This feature caches a copy of the Cloud Firestore data that your app is actively using, so your app can access the data when the device is offline.

Can I use Firebase with react native?

To get started, you must first setup a Firebase project and install the "app" module. React Native Firebase is the officially recommended collection of packages that brings React Native support for all Firebase services on both Android and iOS apps.

How do I use react native offline?

To have offline-first functionality when the app is launched and there is no connection, you will need to add redux-persist to your app. This enables it to store a snapshot of the state of your app to the device's memory and rehydrate the state when the app is launched.


1 Answers

Alternatively, you can use Firestack, which is a native library that works with both iOS and Android on react native.

Offline support is enabled along with storage, the real-time database, authentication, remote configuration (in development), etc.

(disclosure: I am one of the primary authors of Firestack)

like image 128
user2552643 Avatar answered Oct 20 '22 17:10

user2552643