---
url: >-
  https://lit-ui-router.dev/reference/ui-router-server/ssr-client/functions/seed.md
---
[ui-router-server](../../index.md) / [ssr-client](../index.md) / seed

# Function: seed()

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

Defined in: [ssr-client.ts:153](https://github.com/simshanith/lit-ui-router/blob/6e47ef8d8a4b24e99c074fb5c8c9cfaddfdb36a4/packages/ui-router-server/src/ssr-client.ts#L153)

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.

A value a transporter carried is rebuilt by the transporter of the same name
in [\`transport\`](../interfaces/SeedOptions.md#transport) before it is adopted. When
that transporter is missing, or its `decode` throws, only that resolve runs
its function, and in development `seed` warns.

The seed disarms itself once a transition succeeds.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `router` | [`UIRouter`](https://ui-router.github.io/core/docs/latest/classes/_router_.uirouter.html) | the client router, its states registered |
| `payload` | [`ResolvePayload`](../../ssr/interfaces/ResolvePayload.md) | `undefined` | the payload `dehydrate` drew, as parsed from the document, or `undefined` when there is none |
| `options?` | [`SeedOptions`](../interfaces/SeedOptions.md) | the transporters that rebuild values beyond plain JSON |

## 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 type { UIRouter } from '@uirouter/core';
import type { ResolvePayload } from 'ui-router-server/ssr';
import { seed } from 'ui-router-server/ssr/client';

declare const router: UIRouter;
declare const payload: ResolvePayload | undefined;

seed(router, payload);
router.urlService.listen();
router.urlService.sync();
```
