Skip to content

ui-router-server / ssr-client / seed

Function: seed() ​

ts
function seed(router, payload): () => void;

Defined in: ssr-client.ts:47

Seeds router with a resolve payload, so the transition it was drawn for adopts the payload's values in place of running their resolve functions.

Call it before the router starts. The boot transition is still a real transition, with every hook it would fire; only the resolves change. When its target state and url parameters are the ones the payload was drawn for, each entering state's resolves in the payload are pre-resolved with the payload's values. Every other resolve runs its function as it would without a payload: a resolve the payload does not carry, a NOWAIT resolve, every resolve of a transition drawn for another state or other parameters, and every resolve when payload is undefined. A transition that redirects is checked against the payload again as its successor.

The seed disarms itself once a transition succeeds.

Parameters ​

ParameterTypeDescription
routerUIRouterthe client router, its states registered
payloadResolvePayload | undefinedthe payload dehydrate drew, as parsed from the document, or undefined when there is none

Returns ​

a function that disarms the seed

() => void

Throws ​

a TypeError, before any hook is registered, when payload.resolves or a state's entry in it is null or missing

Example ​

ts
import { seed } from 'ui-router-server/ssr/client';

seed(router, payload);
router.start();