Skip to content
Discussion options

You must be logged in to vote

The service worker usually does not need to know about TanStack Router specifically. Treat it as two layers: the service worker caches the app shell/static assets and provides a navigation fallback, while TanStack Query owns the data cache/offline behavior.

For the query side, use networkMode: offlineFirst, a persisted Query cache, and IndexedDB for non-trivial data. Router loaders can call queryClient.ensureQueryData(...), but the offline guarantee comes from prefetching the needed queries while online and persisting the Query cache; the router just reads from that cache when the route is visited offline.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by t0rbik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants