
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: QueryCachecache that should be dehydratedshouldDehydrate: (query: Query) => booleantrue to include this query in dehydration, or false otherwiseshouldDehydrate: () => true to include all queriesReturns
dehydratedState: DehydratedStatecache at a later pointThe latest TanStack news, articles, and resources, sent to your inbox.