lit-ui-router-ssr / lit-ui-router-ssr / PrerenderOptions
Interface: PrerenderOptions
Defined in: packages/lit-ui-router-ssr/src/prerender.ts:81
Options for prerender: 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 |
|---|---|---|---|---|
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 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`, 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 dehydrate: { shouldDehydrate: ({ token }) => token !== 'manifest', transport, }, | - | packages/lit-ui-router-ssr/src/prerender.ts:169 |
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:106 |
dryRun? | boolean | Plans everything and writes nothing — neither pages nor the rules file. | Omit.dryRun | packages/ui-router-server/dist/prerender.d.ts:114 |
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. | - | packages/lit-ui-router-ssr/src/prerender.ts:125 |
extraRules? | RedirectLine[] | Lines prepended to the generated ones, verbatim — a site's own legacy redirects. | Omit.extraRules | packages/ui-router-server/dist/prerender.d.ts:100 |
mounts? | Record<string, MountConfig<readonly RouteDeclaration[]>> | The mount table, compiled here — or pass an already-compiled resolver. | Omit.mounts | packages/ui-router-server/dist/prerender.d.ts:50 |
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:81 |
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:143 |
outDir | string | Directory the files are written under. | Omit.outDir | packages/ui-router-server/dist/prerender.d.ts:56 |
paths | | Iterable<string, any, any> | AsyncIterable<string, any, any> | Every path to ask for a verdict. Redirect and notFound paths belong here too. | Omit.paths | packages/ui-router-server/dist/prerender.d.ts:54 |
payload? | (transition, context) => ResolvePayload | undefined | Draws the resolve payload for a rendered page by hand, in place of `dehydrate`: handed the transition the router last landed, once 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: 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:188 |
renderShell | (verdict, context) => string | TemplateResult | Promise<string | TemplateResult> | Renders one shell verdict. 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 to the path before it returns. | - | packages/lit-ui-router-ssr/src/prerender.ts:97 |
resolver? | ServerRouter<RouteDeclaration> | A resolver from createServerRouter, instead of mounts. | Omit.resolver | packages/ui-router-server/dist/prerender.d.ts:52 |
responses? | Readonly<Record<string, ResponseHandler<never>>> | Handlers for the router's response states, keyed by state name, as responder takes them. A path that matches one settles 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 at origin. Without this option, a response state throws. | - | packages/lit-ui-router-ssr/src/prerender.ts:135 |
root? | EventTarget | The render's root event target. A bare new EventTarget() is created when none is passed; either way 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:114 |
router | UIRouterLit | The router the render reads: provided on 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:90 |
rules? | "none" | "_redirects" | ((lines) => void | Promise<void>) | '_redirects' (default) writes the Cloudflare Pages / Netlify file; 'none' writes nothing and leaves PrerenderResult.rules to the caller; a function receives the lines and writes whatever the host reads. No SPA catch-all is ever written — one turns every 404 into a 200. | Omit.rules | packages/ui-router-server/dist/prerender.d.ts:98 |
trailingSlash? | "both" | "exact" | 'both' (default) emits every generated redirect line twice, with and without the trailing slash: a static host that appends one would otherwise miss the rule. Shell verdicts need no rules line — they are written as <subpath>/index.html, which both spellings reach — but a host that reaches it by redirecting <subpath> to <subpath>/ boots the client at the slashed url, so the client's strictMode(false) and the mount's config: { strict: false } must both admit it. | Omit.trailingSlash | packages/ui-router-server/dist/prerender.d.ts:110 |
write? | FileWriter | Writes a file. Defaults to node:fs, imported lazily on first write. | - | packages/lit-ui-router-ssr/src/prerender.ts:145 |