prerender
Renders pages to static files with the production handler.
Renders pages to static files with the production handler. Each path is requested like a
browser would (a GET with an origin), the response must be an allowed status, and the body is
written under outDir. Paths are validated, output files are checked to stay inside outDir,
two paths may not map to one file, and page count, size and time are bounded.
Import#
ts
import { prerender } from "@shadow-js/dusk/static";
Signature#
ts
async function prerender(options: PrerenderOptions): Promise<PrerenderResult>
Parameters#
| Name | Description |
|---|---|
options |
What to render and where to write it. |
Returns#
The files written.
Throws#
- PrerenderError
PRERENDER_PATH_REJECTED,PRERENDER_PATH_CONFLICT,PRERENDER_MAX_PAGES,PRERENDER_NON_OK,PRERENDER_REDIRECT,PRERENDER_PAGE_TOO_LARGE.
Examples#
ts
await prerender({ handler, outDir: "dist/static", paths: ["/", "/about", "/posts/1"] });