Skip to content
brought to you byVoidZero

Edge Prerendering ​

Prerender pages at deploy time so the first visitor receives cached HTML.

Static pages (no params) ​

Export prerender = true from the companion .server.ts file:

ts
// pages/about.server.ts
export const prerender = true;

Pages without dynamic params do not need getPrerenderPaths().

Dynamic pages (with params) ​

For pages with URL params, also export getPrerenderPaths() to specify which param combinations to prerender. Annotate the return type with PageParams for that page's URL pattern, such as /blog/:slug for pages/blog/[slug].server.ts. TypeScript then requires each object to include those params, so a missing or misspelled key is a type error. Void does not infer this type from the filename.

ts
// pages/blog/[slug].server.ts
import type { PageParams } from 'void/routes';

export const prerender = true;

export async function getPrerenderPaths(): Promise<PageParams<'/blog/:slug'>[]> {
  return [{ slug: 'hello-world' }, { slug: 'getting-started' }];
}

Each object must include every param in the page path. Values can be strings or numbers, and Void URL-encodes them. A single-segment param such as [slug] cannot contain /. For nested paths, use a catch-all page such as pages/docs/[...slug] and return { slug: 'guides/intro' }. If an entry is invalid, void deploy fails. The error names the server file and the entry index.

Custom SSR ​

In custom SSR mode (src/main.ssr.ts), export getPrerenderPaths() at the top level. Since there's no file-based routing, return full path strings:

ts
// src/main.ssr.ts
export const prerender = true;

export async function getPrerenderPaths(): Promise<string[]> {
  return ['/', '/about', '/blog/hello-world'];
}

Annotate this return type as an array of path strings. Use PageParams on file-based pages, where the function returns param objects.

Relationship to revalidation ​

Setting routing.isr: false in void.config.ts disables ISR and this edge-prerendering behavior, including per-page exports. It does not disable build-time HTML generation with output: "static".

Prerendered pages default to a one-year revalidate TTL. Deploys clear the ISR cache.

Override the TTL per page:

ts
// pages/about.server.ts
export const prerender = true;
export const revalidate = 3600;

If the cached page expires before your next deploy, the next request waits for a fresh render.

Behavior details ​

  • Prerender happens once per deployment, before traffic is routed to the new version. Prerendered pages are cached at the edge.
  • Only paths with a positive revalidate TTL are prerendered (TTL 0 is skipped).
  • Prerender failures are logged but never block the deploy. The page will render on the first request as usual.