
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 persisten locations. It only includes currently successful queries by default.
import { dehydrate } from 'react-query/hydration'const dehydratedState = dehydrate(queryClient, {shouldDehydrateQuery,})
Options
client: QueryClientqueryClient that should be dehydratedoptions: DehydrateOptionsdehydrateMutations: booleandehydrateQueries: booleanshouldDehydrateMutation: (mutation: Mutation) => booleantrue to include this mutation in dehydration, or false otherwiseshouldDehydrateQuery: (query: Query) => booleantrue to include this query in dehydration, or false otherwiseshouldDehydrateQuery: () => true to include all queriesReturns
dehydratedState: DehydratedStatequeryClient at a later pointThe latest TanStack news, articles, and resources, sent to your inbox.