dehydrate
creates a frozen representation of a cache
that can later be hydrated with Hydrate
, useHydrate
, or hydrate
. This is useful for passing prefetched queries from server to client or persisting queries to localstorage or other persistent locations. It only includes currently successful queries by default.
import { dehydrate } from 'react-query/hydration'const dehydratedState = dehydrate(queryClient, {shouldDehydrateQuery,})
Options
client: QueryClient
queryClient
that should be dehydratedoptions: DehydrateOptions
dehydrateMutations: boolean
dehydrateQueries: boolean
shouldDehydrateMutation: (mutation: Mutation) => boolean
true
to include this mutation in dehydration, or false
otherwiseshouldDehydrateQuery: (query: Query) => boolean
true
to include this query in dehydration, or false
otherwiseshouldDehydrateQuery: () => true
to include all queriesReturns
dehydratedState: DehydratedState
queryClient
at a later pointThe latest TanStack news, articles, and resources, sent to your inbox.