Make an offline app
Hello,
I have a Capacitor mobile app, and I decided to use react-query for it's cache system (and for many other things), but I'm still new with that library and I'm not sure on how it will behave and how should I use it.
My goal is to make my app available offline, by showing the last data fetched. So I found a way to use a CordovaSQLite driver to make an
asyncStoragePersister
, to save the data in a safe and sustainable way.
So my first thought was that if there is no connection, the request will fail but I'll still be able to get persisted data (if its exist), and make the app works without having to setup a store or anything like that. But after some tries using the Macos Network Link Conditioner
, it seems that the first time I try the query without connection I do get my data, but if I fetch again, it will replace it by the http error that occured because there is no connection.
So, can someone help me to understand how it works and if the library by itself fit for this need ? Because I'm maybe just wrong and it doesn't apply for this kind of usage and I need to add a layer to save those datas.
Thanks!0 Replies