0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-18 19:33:22 +00:00
query/docs/framework/angular/reference/functions/hydrate.md
Wonsuk Choi d169ee8778
docs(*): add property tables and overload overviews to reference pages and keep declared alias names (#11758)
* docs(*): add parameter and result property tables to reference function pages and an overview to overloaded ones

* docs(*): link to the base type's properties when a parameter or result type has no property table

* docs(framework/*/reference): regenerate reference docs

* docs(framework/*/reference): regenerate reference docs

* chore(scripts/generate-docs): restore the 'dirname' import that the merge dropped

* docs(framework/*/reference): regenerate reference docs

* docs(scripts/generate-docs): label overloads in the overview with their declared parameter and return types

* docs(framework/*/reference): regenerate reference docs

* docs(scripts/generate-docs): convert declared intersection types from the source so signatures keep their alias names

* docs(framework/*/reference): regenerate reference docs

* docs(scripts/generate-docs): reword a comment to avoid the unknown word 'inlines'

* docs(scripts/generate-docs): skip a parameter table on overloaded pages when its heading is missing
2026-10-06 02:38:27 +09:00

2.7 KiB

id title
hydrate hydrate
function hydrate(
   client: QueryClient, 
   dehydratedState: Partial<DehydratedState>, 
   options?: HydrateOptions): void;

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

Restores a DehydratedState (as produced by dehydrate) into a QueryClient's cache, typically to seed the client with data already fetched on the server. mutations and queries are each optional on dehydratedState. Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated when the dehydrated data is newer than what's already cached. Newly built queries have their fetchStatus reset to 'idle' so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight promise, it is resumed via query.fetch() (reusing that promise as initialPromise) rather than re-invoking queryFn.

Parameters

client

QueryClient

The client whose cache is restored into.

dehydratedState

Partial<DehydratedState>

The dehydrated state, e.g. produced by dehydrate on the server.

dehydratedState properties

Built from DehydratedState. See the type above for what it changes.

options?

HydrateOptions

defaultOptions merged into every restored query and mutation (on top of the client's defaultOptions.hydrate), and deserializeData to reverse serializeData.

options properties

Property Type Description
defaultOptions? object Options applied to the queries and mutations restored from the dehydrated state.
defaultOptions.deserializeData? TransformerFn Transforms a query's data after it is read from the dehydrated state, reversing serializeData.
defaultOptions.mutations? MutationOptions<unknown, Error, unknown, unknown> Default options merged into every mutation restored from the dehydrated state.
defaultOptions.queries? QueryOptions<unknown, Error, unknown, readonly unknown[], never> Default options merged into every query restored from the dehydrated state.

Returns

void

Example

// dehydratedState was produced by `dehydrate` on the server
// and sent to the client, e.g. embedded in server-rendered markup.
const queryClient = new QueryClient()

hydrate(queryClient, dehydratedState)