Skip to content

ui-router-server / prerender / PrerenderOptions

Interface: PrerenderOptions ​

Defined in: prerender.ts:105

Options for prerender.

Properties ​

PropertyTypeDescriptionDefined in
base?stringThe 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.prerender.ts:154
dryRun?booleanPlans everything and writes nothing — neither pages nor the rules file.prerender.ts:209
extraRules?RedirectLine[]Lines prepended to the generated ones, verbatim — a site's own legacy redirects.prerender.ts:205
mounts?Record<string, MountConfig<readonly RouteDeclaration[]>>The mount table, compiled here — or pass an already-compiled resolver.prerender.ts:107
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.prerender.ts:183
outDirstringDirectory the files are written under.prerender.ts:141
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.prerender.ts:121
pathsIncludeBase?booleanWhether 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.prerender.ts:139
render(verdict, context) => | string | RenderedRedirect | Promise<string | RenderedRedirect>Renders one shell verdict to the file's full text, document included, or answers a RenderedRedirect for a page whose render found it redirects, such as a redirectTo function settle followed: the path gets a rules line and no page. Renders run one at a time, in enumeration order, then the 404 document, which must render a page.prerender.ts:162
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'.prerender.ts:113
respond?(verdict, context) => | Response | Promise<Response>Answers one response verdict: settle the state and run the handler bound to its name. A 2xx answer's body, read as text, is written to the path its url spells (badge.svg; index.html at the mount root), its headers dropped; a 3xx becomes a rules line to its Location; any other status throws. Runs in the same sequence as render. lit-ui-router-ssr's prerender supplies it from the handlers bound by state name.prerender.ts:174
rules?RulesWriter | "_redirects" | "none"'_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.prerender.ts:203
writeFileWriterWrites each file; pass one over node:fs, a virtual fs, or memory.prerender.ts:207