Open History to see the last commit
1---
2id: dehydrateQuery
3title: dehydrateQuery
4---
5β
6```ts
7function dehydrateQuery(
8 query: Query,
9 serializeData?: TransformerFn,
10 shouldRedactErrors?: (error: unknown) => boolean): DehydratedQuery;
11```
12β
13Defined in: [packages/query-core/src/hydration.ts:178](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L178)
14β
15Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g.
16`queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the
17de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight
18promise is dehydrated too so it can be resumed on the other side instead of re-fetched.
19β
20## Parameters
21β
22### query
23β
24[`Query`](../classes/Query.md)
25β
26The query to dehydrate.
27β
28### serializeData?
29β
30`TransformerFn`
31β
32Optional transform applied to `query.state.data` before it is included in the snapshot.
33β
34### shouldRedactErrors?
35β
36(`error`: `unknown`) => `boolean`
37β
38Optional predicate; if it returns `false` for the promise's rejection error, that
39error is kept as-is instead of being redacted.
40β
41## Returns
42β
43`DehydratedQuery`
44β
45The dehydrated query.