Skip to content
0

katanakit-js / dehydrateQuery

Function: dehydrateQuery() ​

ts
function dehydrateQuery(
   query, 
   serializeData?, 
   shouldRedactErrors?
): DehydratedQuery;

Defined in: node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:2882

Dehydrates a single Query into a serializable DehydratedQuery snapshot. Note that most query config (e.g. queryFn, staleTime) is not dehydrated but instead meant to be configured again when consuming the de/rehydrated data, typically with useQuery on the client. If the query is still pending, its in-flight promise is dehydrated too so it can be resumed on the other side instead of re-fetched.

Parameters ​

ParameterTypeDescription
queryQueryThe query to dehydrate.
serializeData?TransformerFnOptional transform applied to query.state.data before it is included in the snapshot.
shouldRedactErrors?(error) => booleanOptional predicate; if it returns false for the promise's rejection error, that error is kept as-is instead of being redacted.

Returns ​

DehydratedQuery

Released under the MIT License.