HairLessDude
HairLessDude

Reputation: 289

Is it possible to create offline first apps with React-Native?

From what I've understood offline first apps need a way to tell if the user is connected; if not, it stores changes locally and syncs with the remote server when online.

The way I've found to do this with web apps is by using pouchdb on the client communicating with an api connected to a couchdb database. Or by using Firebase.

Is it possible to have similar functionality using React-Native? Maybe by using the pouchdb-async-storage adapter. Are there other alternatives out there for local-remote data syncing?

Upvotes: 9

Views: 4567

Answers (3)

Bruno Reis
Bruno Reis

Reputation: 326

pouchdb-react-native is a good lib to look at

Upvotes: 1

stockulus
stockulus

Reputation: 39

I build an AsycStorage Adapter for PouchDB, including Polyfills for React-native. Properly that helps.

asyncstorage adapter for PouchDB

Upvotes: 3

Hugo
Hugo

Reputation: 3888

I haven't actually implemented offline capabilities in a React-Native app but from looking at the docs, the APIs provided enable you to do so.

The APIs you're looking for are AsyncStorage (for data persistence) and to detect the connection info use NetInfo.

You're on the right track about using pouchdb. The part you will most likely have to write yourself is the syncing script (I'm not sure you can do this in the background but I may be wrong).

Let me know how you get on or if you want to discuss further @hugo__df on twitter :)

Upvotes: 1

Related Questions