Ability to persist only specific queries #8323
-
Hi there! I'm excited about TanStack Query persistQueryClient feature. It really helps building offline-first app. Reading the docs and looking at the examples I can't understand is there ability to store only specific queries inside persistent storage. Is it like "all or nothing" approach? Using TanStack Query I expect to have optionally choose what kind of query I would like to store. For example:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
step 1: add the
step 2: filter on the
you can also invert it and per default, persist everything and then opt-out when persist is set to false, that’s up to you. |
Beta Was this translation helpful? Give feedback.
step 1: add the
meta
option to the queries that you want to persist:step 2: filter on the
PersistQueryClientProvider
what you want to persist:defaultShouldDehydrateQuery
can be imported and makes sure that only successful queries are dehydrated.you can also invert it and per default, persist everything and then opt-out when persist is set to false, …