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

3

9

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?

Dorita answered 26/10, 2015 at 3:51 Comment(3)
According to user @modusjesus from reddit: It's extremely difficult because the runtime is suspended when the screen is locked. There hasn't been a solution to this yet.Dorita
Have you found a solution to this? This is exactly what I'm trying to do.Secessionist
Haven't been looking anymore... so I guess not.Dorita
V
3

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

asyncstorage adapter for PouchDB

Vacuva answered 18/4, 2016 at 8:49 Comment(2)
This might be exactly what we've been waiting for.Dorita
Project moved to GitHub / npmVacuva
M
1

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 :)

Management answered 27/10, 2015 at 9:52 Comment(0)
H
1

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

Helices answered 17/8, 2017 at 18:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.