Skip to content

ui-router-server / ssr / dehydrate

Function: dehydrate() ​

ts
function dehydrate(transition): DehydrateResult;

Defined in: dehydrate.ts:54

Draws the resolve payload from a transition that has landed, such as the one `settle` hands back: every resolved value of every state on its path, keyed by state name and token, and the state and url parameters it was drawn for.

Only the resolves a state declares with a string token are drawn. A value goes in when it is plain JSON data: null, a boolean, a string, a finite number, or an array or plain object of those, with no cycle. Anything else (a Date, a Map, a class instance, undefined, NaN) is listed in `unserializable` instead and re-runs on the client, so an adopted value never differs from the one the server resolved.

A NOWAIT resolve stays with the client: it is neither awaited nor drawn, nor listed, and the client runs it as it would without a payload.

Parameters ​

ParameterTypeDescription
transitionTransitiona transition that has landed

Returns ​

DehydrateResult

the payload, and the resolves left out of it

Example ​

ts
import { dehydrate, settle } from 'ui-router-server/ssr';

const { payload, unserializable } = dehydrate(await settle(router, path));

for (const { state, token } of unserializable)
  console.warn(`${path}: ${state}.${token} re-runs on the client`);