Is there a way to have an offline mode? requests queue? #988
Replies: 10 comments 9 replies
-
I'm also interested in this. We currently use a very customized setup of redux + redux offline in combination with apollo client in order to achieve this. Does react query have any offline concept at all (eg mutations should only run in sequence when back online) or just "retry" whem failed? |
Beta Was this translation helpful? Give feedback.
-
Also super interested in this use case. Maybe some overview example on how this can be archived in the best way possible using RQ alone or with some other tool. 💯 . |
Beta Was this translation helpful? Give feedback.
-
V3 has support for offline queries and mutations: https://react-query-beta.tanstack.com/ |
Beta Was this translation helpful? Give feedback.
-
can anyone from the core dev team of react-query tell us what are your plans for offline support? |
Beta Was this translation helpful? Give feedback.
-
Also super interested in this. I have an offline-first cordova app, and the main issue preventing to use react-query is the handling of app craches. The hydrate/dehydrate API implies to know when to dehydrate in order to persist, where it would be far more convenient to maintain a persisted state in localForage / indexedDB (where storage is not limited to 5mb) during all the app lifecycle. |
Beta Was this translation helpful? Give feedback.
-
Presuming you use GraphQL, then urql/graphcache or the Offix DataStore (forked from Apollo Client, and works similarly to AWS Amplify DataStore but without the cruft) currently looks like the best options. Offline turns out to be quite a bit more complex than people originally suspect (due to conflict resolution which requires server compatibility/strategies):
https://gianlucazuccarelli.medium.com/offix-2-0-de59409b16d2 |
Beta Was this translation helpful? Give feedback.
-
I'm happy to say that proper online / offline support will be one of the flagship features for v4, which I'm currently working on. please have a look at my api proposal in this issue: I'm happy to take further input directly on the issue, if there are any cases that you think that I've missed. I have a draft PR already: but it's not too late to change the api, especially in terms of naming etc.
regarding mutations, I don't have much changes planned for retry / offline mutations. The persist plugins will be come "stable" in v4, so we'll remove the "experimental" in the name, and it will then be the best way to achieve that functionality. I don't think there are many manual steps you need to do. You can dehydrate the client independent of if you are online or offline as only paused mutations will be persisted. If you need to check if you are online or not, you can use the exported |
Beta Was this translation helpful? Give feedback.
-
I am also interested in offline mode in React-Query, can we have a rough idea when v4 is going to be released? I am evaluating if we should use React-Query for offline support or go for some other solution if the release is not going to happen in near future. |
Beta Was this translation helpful? Give feedback.
-
Leaving this question here: Has anyone solved persisting mutations across hard reloads (closing the browser tab or the native application) by using something like indexDB. The current implementation for firing paused mutations when coming back online via |
Beta Was this translation helpful? Give feedback.
-
It's a known caveat that we need to document better in v4. The To work around this, you have to use a default
then, you can just use:
the defaults will also be picked up when continuing mutations from a restore. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm working on a React Native app that needs to work offline and I'm looking for the best way to handle data fetching.
react-query seems to address a lot of problems I have encountered with redux based apps but I don't find how I could handle an offline mode?
What I'm trying to achieve is performing an optimistic update if offline and send the requests as soon as mobile reach network again.
Is it something I could do with react-query?
Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions