lit-ui-router-ssr / lit-ui-router-ssr / PrerenderOptions
Interface: PrerenderOptions
Defined in: packages/lit-ui-router-ssr/src/prerender.ts:113
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 |
|---|---|---|---|---|
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 are written as given. Defaults to the resolver's own base; a different value throws, as does a relative or full-URL base. A mounts table keyed by the base compiles as createServerRouter({ base, mounts }) would. Either way, paths lie under the base, with it taken off. | Omit.base | packages/ui-router-server/dist/prerender.d.ts:115 |
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 nocheck dehydrate: { shouldDehydrate: ({ token }) => token !== 'manifest', transport, }, | - | packages/lit-ui-router-ssr/src/prerender.ts:208 |
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:142 |
dryRun? | boolean | Plans everything and writes nothing — neither pages nor the rules file. | Omit.dryRun | packages/ui-router-server/dist/prerender.d.ts:164 |
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; put LitElementRenderer after LightElementRenderer to draw it. | - | packages/lit-ui-router-ssr/src/prerender.ts:163 |
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:160 |
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:68 |
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:140 |
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:182 |
outDir | string | Directory the files are written under. | Omit.outDir | packages/ui-router-server/dist/prerender.d.ts:102 |
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 when 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:82 |
pathsIncludeBase? | boolean | Whether each of paths spells the 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 from createServerRouter({ base, mounts }) or a 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:100 |
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: 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:227 |
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. 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:133 |
resolver? | ServerRouter<RouteDeclaration> | A resolver from createServerRouter, instead of 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:74 |
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 under base at origin. Without this option, a response state throws. | - | packages/lit-ui-router-ssr/src/prerender.ts:174 |
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:150 |
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:122 |
rules? | "none" | "_redirects" | RulesWriter | '_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, 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:158 |
write? | FileWriter | Writes a file. Defaults to node:fs, imported lazily on first write. | - | packages/lit-ui-router-ssr/src/prerender.ts:184 |