reactjsprogressive-web-appsnext-pwa

Is it possible to reliably buffer outgoing POST requests from an offline React PWA?


Is there any way to have a service worker intercept and buffer POST requests from my React components and delivery them when network connectivity allows?

I'm planning on using next-pwa to support offline operation of an app which needs the user to enter equipment readings in an area of poor network connectivity. Reliable delivery of collected data is vital and I can't simply provide a 'try again later' message as disconnected periods may be lengthy.

I suppose what I'm thinking of is a PWA version of an outgoing message queue such as ActiveMQ or MSMQ.


Solution

  • You could try using TanStackQuery, which seems to support automatically retrying mutations when offline.

    You can also persist mutations, which could be helpful for supporting long offline intervals

    Disclaimer: I have used TanStack Query, but I never used it for implementing offline mutations - I just found it in the docs