[]previous and next page

PrerenderOptions (@shadow-js/dusk/vite)

What to prerender at build time.

What to prerender at build time.

Import#

ts
import type { PrerenderOptions } from "@shadow-js/dusk/vite";

Signature#

ts
interface PrerenderOptions {
  /** Paths to render in addition to the routes that declare `export const prerender`. */
  readonly routes?: readonly string[];
  /**
   * More paths to render: a list, or a function that returns one (it may be async). Use it for the
   * params of a dynamic route when the list is easier to write here than in the route file.
   */
  readonly entries?: readonly string[] | (() => readonly string[] | Promise<readonly string[]>);
  /**
   * Follows the internal links of the rendered pages. `true` follows three hops and adds at most 500
   * pages; an object sets `depth` (hops from the listed paths, at least 1) and `limit` (pages the
   * crawl may add, at least 0). Links to other origins, to fragments, to files (a last segment with
   * a dot) and under `/_dusk` are not followed. Off by default.
   */
  readonly crawlLinks?: boolean | { readonly depth?: number; readonly limit?: number };
  /** Keeps a path (listed or found by the crawl) out when it returns false. */
  readonly filter?: (path: string) => boolean;
  /** Attempts after a page that threw or answered 5xx. Default 0. Max 5. */
  readonly retry?: number;
  /** Called after each page is written. */
  readonly onSuccess?: (page: PrerenderSuccess) => void | Promise<void>;
  /** Called for each page that did not render, listed or found, before the run fails. */
  readonly onError?: (failure: PrerenderFailureEvent) => void | Promise<void>;
  /**
   * Origin of the requests sent to the handler. Default `http://localhost`; when the handler's
   * `security.allowedHosts` does not list `localhost`, the first plain (non-wildcard) host it lists,
   * so a production host list needs no extra setting. A 400 caused by the host check fails the
   * build with a message that names `security.allowedHosts` and the host used.
   */
  readonly origin?: string;
  /** Requests in flight at once. Default 4. */
  readonly concurrency?: number;
  /** A response that is not 200 fails the build. Default true. */
  readonly failOnError?: boolean;
}

Members#

Name Type Description
routes? readonly routes?: readonly string[] Paths to render in addition to the routes that declare export const prerender.
entries? readonly entries?: readonly string[] | (() => readonly string[] | Promise<readonly string[]>) More paths to render: a list, or a function that returns one (it may be async). Use it for the params of a dynamic route when the list is easier to write here than in the route file.
crawlLinks? readonly crawlLinks?: boolean | { readonly depth?: number; readonly limit?: number } Follows the internal links of the rendered pages. true follows three hops and adds at most 500 pages; an object sets depth (hops from the listed paths, at least 1) and limit (pages the crawl may add, at least 0). Links to other origins, to fragments, to files (a last segment with a dot) and under /_dusk are not followed. Off by default.
filter? readonly filter?: (path: string) => boolean Keeps a path (listed or found by the crawl) out when it returns false.
retry? readonly retry?: number Attempts after a page that threw or answered 5xx. Default 0. Max 5.
onSuccess? readonly onSuccess?: (page: PrerenderSuccess) => void | Promise<void> Called after each page is written.
onError? readonly onError?: (failure: PrerenderFailureEvent) => void | Promise<void> Called for each page that did not render, listed or found, before the run fails.
origin? readonly origin?: string Origin of the requests sent to the handler. Default http://localhost; when the handler's security.allowedHosts does not list localhost, the first plain (non-wildcard) host it lists, so a production host list needs no extra setting. A 400 caused by the host check fails the build with a message that names security.allowedHosts and the host used.
concurrency? readonly concurrency?: number Requests in flight at once. Default 4.
failOnError? readonly failOnError?: boolean A response that is not 200 fails the build. Default true.