TanStack
API Reference

DehydrateOptions

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

Options for dehydrate, controlling which queries/mutations are included in the resulting DehydratedState and how their data/errors are transformed before being serialized (e.g. for embedding in server-rendered markup).

Properties

PropertyTypeDescription
serializeData?TransformerFnTransforms a query's data before it is dehydrated. Useful for non-JSON-serializable data.
shouldDehydrateMutation?(mutation: Mutation) => booleanPredicate to decide whether a given Mutation should be dehydrated. Defaults to defaultShouldDehydrateMutation.
shouldDehydrateQuery?(query: Query) => booleanPredicate to decide whether a given Query should be dehydrated. Defaults to defaultShouldDehydrateQuery.
shouldRedactErrors?(error: unknown) => booleanPredicate to decide whether a query's error should be redacted before dehydration. Errors are redacted (replaced with a generic Error('redacted')) unless this function is provided and returns false for the given error, in which case the original error is kept.