---
url: https://lit-ui-router.dev/reference/lit-ui-router-ssr/index/interfaces/PrerenderOptions.md
---
[lit-ui-router-ssr](../../index.md) / [lit-ui-router-ssr](../index.md) / PrerenderOptions

# Interface: PrerenderOptions

Defined in: [packages/lit-ui-router-ssr/src/prerender.ts:195](https://github.com/simshanith/lit-ui-router/blob/1a50793071790d3899525647afc15c4cd2bd9e91/packages/lit-ui-router-ssr/src/prerender.ts#L195)

Options for [prerender](../functions/prerender.md): those of `ui-router-server/prerender`'s loop, with
a lit render in place of its `render`.

## Extends

* `Omit`<`SitePrerenderOptions`, `"render"` | `"respond"` | `"write"`>

## Properties

| Property | Type | Description | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ |
|  `base?` | `string` | The url path `outDir` is served at, such as Vite's `base`; `/` by default. The mounts stay at `/` and page files don't move: the base goes once onto each generated rules line's `from` and host-absolute `to`. [extraRules](#extrarules) get no base. Defaults to the [resolver](#resolver)'s own `base`; a different value throws, as does a relative or full-URL base. A [mounts](#mounts) table keyed by the base compiles as `createServerRouter({ base, mounts })` would. Either way, [paths](#paths) lie under the base, with it taken off. | `Omit.base` | packages/ui-router-server/dist/prerender.d.ts:132 |
|  `dehydrate?` | `DehydrateOptions` | Draws each rendered page's resolve payload with `dehydrate` from `ui-router-server/ssr`, called with these options on the transition the router last landed, once `template` or `renderShell` has returned a template. The payload's `resolves` go into the page's hydration signature, beside the state and parameters the router stands on, and the client adopts them on boot in place of running those resolve functions. Pass `{}` to draw every resolve `dehydrate` draws by default. Without this option or [\`payload\`](#payload), no page carries resolves. `dehydrate`'s documentation says which values it leaves out and how `shouldDehydrate` and `transport` act. The payload's `transported` marks go into the signature too, so a value a transporter carried is rebuilt when `bootstrap()` gets the same `transport`. **Example** `nocheck dehydrate: { shouldDehydrate: ({ token }) => token !== 'manifest', transport, },` | - | [packages/lit-ui-router-ssr/src/prerender.ts:304](https://github.com/simshanith/lit-ui-router/blob/1a50793071790d3899525647afc15c4cd2bd9e91/packages/lit-ui-router-ssr/src/prerender.ts#L304) |
|  `document?` | (`body`, `context`) => `string` | `Promise`<`string`> | Wraps a rendered body in the page document — the shell html, its `<title>`, its head. Defaults to the body unchanged. This package never parses or rewrites html. | - | [packages/lit-ui-router-ssr/src/prerender.ts:237](https://github.com/simshanith/lit-ui-router/blob/1a50793071790d3899525647afc15c4cd2bd9e91/packages/lit-ui-router-ssr/src/prerender.ts#L237) |
|  `dryRun?` | `boolean` | Plans everything and writes nothing — neither pages nor the rules file. | `Omit.dryRun` | packages/ui-router-server/dist/prerender.d.ts:181 |
|  `elementRenderers?` | `ElementRendererConstructor`\[] | Element renderers passed through to `@lit-labs/ssr`, verbatim. Defaults to `[UiViewRenderer, LightElementRenderer]` — not `@lit-labs/ssr`'s `[LitElementRenderer]`, which wraps every custom element in a declarative shadow root it never asked for. `LightElementRenderer` answers only for a class `LightDomHydrating` branded. A list passed here replaces the default, so keep `LightElementRenderer` in it, ahead of any renderer that writes a shadow root, to draw those elements. Pass `[]` for a render with no `<ui-view>` to fill. A shadow-DOM `LitElement` no renderer in the list answers for renders as its bare tag, empty, and warns once per tag in development; pass `shadowElementRenderers`, which adds `LitElementRenderer` after `LightElementRenderer`, to draw it. | - | [packages/lit-ui-router-ssr/src/prerender.ts:259](https://github.com/simshanith/lit-ui-router/blob/1a50793071790d3899525647afc15c4cd2bd9e91/packages/lit-ui-router-ssr/src/prerender.ts#L259) |
|  `extraRules?` | [`RedirectLine`](RedirectLine.md)\[] | Lines prepended to the generated ones, percent-encoded as they are but given no base — a site's own legacy redirects. | `Omit.extraRules` | packages/ui-router-server/dist/prerender.d.ts:177 |
|  `mounts?` | `Record`<`string`, [`MountConfig`](/reference/ui-router-server/index/interfaces/MountConfig)\<readonly `RouteDeclaration`\[]>> | The mount table, compiled here — or pass an already-compiled [resolver](#resolver). | `Omit.mounts` | packages/ui-router-server/dist/prerender.d.ts:85 |
|  `notFound?` | | `false` | { `file?`: `string`; `probe?`: `string`; } | The 404 document, emitted once from the `otherwise` projection. `false` emits none, and nothing is emitted when the probed mount declares no projection. | `Omit.notFound` | packages/ui-router-server/dist/prerender.d.ts:157 |
|  `onPath?` | (`report`) => `void` | Called once per listed path, in enumeration order, after the path is handled: with its verdict, and the page written or redirect answered for it. Not called for the 404 document. | `Omit.onPath` | packages/ui-router-server/dist/prerender.d.ts:187 |
|  `origin?` | `string` | The origin of the request a response handler gets, such as `https://example.com`. Defaults to `http://lit-ui-router-ssr`, a host that names this package so a url built from it stands out in the output. A handler that answers with paths needs none; pass the site's own origin when a handler builds absolute urls from `request.url`. | - | [packages/lit-ui-router-ssr/src/prerender.ts:278](https://github.com/simshanith/lit-ui-router/blob/1a50793071790d3899525647afc15c4cd2bd9e91/packages/lit-ui-router-ssr/src/prerender.ts#L278) |
|  `outDir` | `string` | Directory the files are written under. | `Omit.outDir` | packages/ui-router-server/dist/prerender.d.ts:119 |
|  `paths` | | `Iterable`<`string`, `any`, `any`> | `AsyncIterable`<`string`, `any`, `any`> | Every path to ask for a verdict. Redirect and notFound paths belong here too. They spell the [base](#base) when [pathsIncludeBase](#pathsincludebase) is on, as it is by default for a router that declares one, and lie under it with it taken off otherwise. | `Omit.paths` | packages/ui-router-server/dist/prerender.d.ts:99 |
|  `pathsIncludeBase?` | `boolean` | Whether each of [paths](#paths) spells the [base](#base), as a host serves it: `/app/about` under `/app/`. When `true`, the base is taken off each path once, before anything else sees it, so the output matches the base-free listing; a path outside the base throws. When `false`, a path is read as given, even one that starts with the base. `pages`, `warnings` and `delegated` report each path as listed. Under base `/` it changes nothing. Defaults to whether the router declares a base: `true` for a [resolver](#resolver) from `createServerRouter({ base, mounts })` or a [mounts](#mounts) table keyed by the base, so a table that spells real urls lists real urls; `false` for a table at `/` stripped under a `base`, so its paths stay the same at any base. The default follows that declaration, never the shape of the paths. | `Omit.pathsIncludeBase` | packages/ui-router-server/dist/prerender.d.ts:117 |
|  `payload?` | (`transition`, `context`) => [`ResolvePayload`](ResolvePayload.md) | `undefined` | Draws the resolve payload for a rendered page by hand, in place of [\`dehydrate\`](#dehydrate): handed the transition the router last landed, once `template` or `renderShell` has returned a template, it returns the payload the page's signature carries, or `undefined` to write none. Passing both this and `dehydrate` throws. **Example** Shape the payload `dehydrate` draws before it is written: `nocheck import { dehydrate } from 'ui-router-server/ssr'; payload: (transition, { path }) => path.startsWith('/drafts/') ? undefined : dehydrate(transition, { transport }).payload,` | - | [packages/lit-ui-router-ssr/src/prerender.ts:324](https://github.com/simshanith/lit-ui-router/blob/1a50793071790d3899525647afc15c4cd2bd9e91/packages/lit-ui-router-ssr/src/prerender.ts#L324) |
|  `renderShell?` | (`verdict`, `context`) => `string` | `TemplateResult` | `Promise`<`string` | `TemplateResult`> | Renders one shell verdict, in place of [template](#template), for a page that needs the verdict or more than a settle. Return a template and this package renders it, behind the hydration signature; return a string and it is written as-is. Async, so a hook may drive [router](#router) to the path before it returns. When the transition the router lands on during the hook was redirected, by a `redirectTo` function for one, the path gets a rules line to where it landed, at the redirecting state's `redirectStatusCode`, and no page: `redirectedTo` from `ui-router-server/ssr` reports it. | - | [packages/lit-ui-router-ssr/src/prerender.ts:228](https://github.com/simshanith/lit-ui-router/blob/1a50793071790d3899525647afc15c4cd2bd9e91/packages/lit-ui-router-ssr/src/prerender.ts#L228) |
|  `resolver?` | [`ServerRouter`](/reference/ui-router-server/index/interfaces/ServerRouter)<`RouteDeclaration`> | A resolver from `createServerRouter`, instead of [mounts](#mounts); its mounts' trailing-slash policies come with it. Any other resolver is read as `'as-requested'`. | `Omit.resolver` | packages/ui-router-server/dist/prerender.d.ts:91 |
|  `responses?` | `Readonly`<`Record`<`string`, [`ResponseHandler`](../type-aliases/ResponseHandler.md)<`never`>>> | Handlers for the router's response states, keyed by state name, as [responder](../functions/responder.md) takes them. A path that matches one settles [router](#router) on it and writes what its handler answers: a 2xx body at the path its url spells, or a 3xx as a rules line. The handler's request is a GET for the path under [base](#base) at [origin](#origin). Without this option, a response state throws. | - | [packages/lit-ui-router-ssr/src/prerender.ts:270](https://github.com/simshanith/lit-ui-router/blob/1a50793071790d3899525647afc15c4cd2bd9e91/packages/lit-ui-router-ssr/src/prerender.ts#L270) |
|  `root?` | `EventTarget` | The render's root event target. A bare `new EventTarget()` is created when none is passed; either way [router](#router) is provided on it, it reaches every render on `eventTargetStack`, and it is returned on the result so the caller can attach providers of its own before the call. | - | [packages/lit-ui-router-ssr/src/prerender.ts:245](https://github.com/simshanith/lit-ui-router/blob/1a50793071790d3899525647afc15c4cd2bd9e91/packages/lit-ui-router-ssr/src/prerender.ts#L245) |
|  `router` | [`UIRouterLit`](/reference/lit-ui-router/core/UIRouterLit) | The router the render reads: provided on [root](#root) for `context-request` and scoped with `withRouterSync` around every render, so `<ui-router>` descendants and the sref attribute directives both find it. | - | [packages/lit-ui-router-ssr/src/prerender.ts:204](https://github.com/simshanith/lit-ui-router/blob/1a50793071790d3899525647afc15c4cd2bd9e91/packages/lit-ui-router-ssr/src/prerender.ts#L204) |
|  `rules?` | `"none"` | `"_redirects"` | `RulesWriter` | `'_redirects'` (default) writes the Cloudflare Pages / Netlify file; `'none'` writes nothing and leaves [PrerenderResult.rules](PrerenderResult.md#rules) to the caller; a function receives the lines and writes whatever the host reads, such as `redirectPages` for a host with no redirect rules. No SPA catch-all is ever written — one turns every 404 into a 200. | `Omit.rules` | packages/ui-router-server/dist/prerender.d.ts:175 |
|  `template?` | (`router`) => `TemplateResult` | The page's template, read from [router](#router) once it stands on the path: for each shell verdict, `router` is settled on the path within its mount, trailing slash kept, with `settle` from `ui-router-server/ssr` and the template this returns is rendered, as a [renderShell](#rendershell) hook that settles and returns `template(router)` would. Pass this or `renderShell`, not both. The 404 document's probe path is settled too, so a mount that projects an `otherwise` needs the router to declare an `otherwise` rule of its own, or the render rejects. | - | [packages/lit-ui-router-ssr/src/prerender.ts:215](https://github.com/simshanith/lit-ui-router/blob/1a50793071790d3899525647afc15c4cd2bd9e91/packages/lit-ui-router-ssr/src/prerender.ts#L215) |
|  `write?` | [`FileWriter`](../type-aliases/FileWriter.md) | Writes a file. Defaults to `node:fs`, imported lazily on first write. | - | [packages/lit-ui-router-ssr/src/prerender.ts:280](https://github.com/simshanith/lit-ui-router/blob/1a50793071790d3899525647afc15c4cd2bd9e91/packages/lit-ui-router-ssr/src/prerender.ts#L280) |
