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