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(cache, {shouldDehydrate,})
Options
cache: QueryCache
cache
that should be dehydratedoptions: DehydrateOptions
shouldDehydrate: (query: Query) => boolean
true
to include this query in dehydration, or false
otherwiseshouldDehydrate: () => true
to include all queriesReturns
dehydratedState: DehydratedState
cache
at a later pointThe latest TanStack news, articles, and resources, sent to your inbox.