Files
upstream-tanstack-query/docs/framework/angular/reference/functions/dehydrate.md
upstream-mirror 3a013ccdfe
Some checks failed
autofix.ci / autofix (push) Failing after 4s
Release / Release (push) Has been skipped
GitHub Actions Security Analysis / Run zizmor (push) Failing after 2s
snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:13:08 +05:00

1.1 KiB

id, title
id title
dehydrate dehydrate
function dehydrate(client, options): DehydratedState;

Defined in: packages/query-core/src/hydration.ts:207

Dehydrates a QueryClient's cache (queries and mutations) into a plain, serializable DehydratedState, typically to embed in server-rendered markup and later restore into a client-side QueryClient via hydrate. Which queries/mutations are included, and how their data/errors are transformed, is controlled by options, falling back to the client's dehydrate default options, and finally to defaultShouldDehydrateQuery / defaultShouldDehydrateMutation.

Parameters

client

QueryClient

options

DehydrateOptions = {}

Returns

DehydratedState

Example

const queryClient = new QueryClient()

await queryClient.prefetchQuery({
  queryKey: ['posts'],
  queryFn: getPosts,
})

const dehydratedState = dehydrate(queryClient)