RouteRule
The settings of one route rule.
The settings of one route rule. Every field is optional.
Import#
ts
import type { RouteRule } from "@shadow-js/dusk/server";
Signature#
ts
interface RouteRule {
/** `false` turns caching off for the path; an object sets the ISR options. */
readonly cache?: false | RouteCacheOptions;
/** Seconds a rendered page is fresh (the default when the page exports no `revalidate`); `false` never. */
readonly revalidate?: number | false;
/** Renders the path at build time. Only for a literal path (no parameters or wildcards). */
readonly prerender?: boolean;
/** Response headers. */
readonly headers?: Readonly<Record<string, string>>;
/**
* The `cache-control` of the path's responses that set none, in place of `security.defaultCacheControl`. A string
* sets it; `false` leaves the responses without it. A `cache-control` the route or a `headers` rule sets wins.
*/
readonly cacheControl?: string | false;
/** Redirects the path. */
readonly redirect?: { readonly to: string; readonly statusCode?: RedirectStatus };
/** `false`: the document is served without rendering the route (the browser renders it). */
readonly ssr?: false;
/** `false`: the page ships no client JavaScript. */
readonly csr?: boolean;
}
Members#
| Name | Type | Description |
|---|---|---|
cache? |
readonly cache?: false | RouteCacheOptions |
false turns caching off for the path; an object sets the ISR options. |
revalidate? |
readonly revalidate?: number | false |
Seconds a rendered page is fresh (the default when the page exports no revalidate); false never. |
prerender? |
readonly prerender?: boolean |
Renders the path at build time. Only for a literal path (no parameters or wildcards). |
headers? |
readonly headers?: Readonly<Record<string, string>> |
Response headers. |
cacheControl? |
readonly cacheControl?: string | false |
The cache-control of the path's responses that set none, in place of security.defaultCacheControl. A string sets it; false leaves the responses without it. A cache-control the route or a headers rule sets wins. |
redirect? |
readonly redirect?: { readonly to: string; readonly statusCode?: RedirectStatus } |
Redirects the path. |
ssr? |
readonly ssr?: false |
false: the document is served without rendering the route (the browser renders it). |
csr? |
readonly csr?: boolean |
false: the page ships no client JavaScript. |