RenderOptions
Options of renderToString, and the base of AsyncRenderOptions.
Options of renderToString, and the base of AsyncRenderOptions.
Import#
ts
import type { RenderOptions } from "@shadow-js/web/server";
Signature#
ts
interface RenderOptions {
/**
* Prefix of every hydration key: letters, digits, `_` and `-` only. Give each app rendered into the
* same page its own id, and pass the same id to `hydrate()`.
* @default "0"
*/
readonly renderId?: string;
/**
* Collects the tags `useHead`, `<Title>`, `<Meta>`, ... register while rendering (see
* `createServerHead`).
* @default undefined (head tags are not collected)
*/
readonly head?: ServerHead;
/**
* Collects the markup of the portals the render produces (see {@link createServerPortals}). Emit
* `portals.html()` at the end of `<body>` once the render is done.
* @default undefined (a portal renders nothing on the server)
*/
readonly portals?: ServerPortals;
/**
* Receives an error an `ErrorBoundary` of the render caught. The boundary's fallback is in the markup,
* so the caller can answer the request with the status of the error. Called once per caught error.
* For {@link renderToStringAsync} only the last pass is reported.
* @default undefined (caught errors are not reported)
*/
readonly onCaughtError?: (error: unknown) => void;
/**
* Receives an error no boundary took. With it the render does not throw that error and the markup
* lacks the part that failed.
* @default undefined (the error propagates out of the render)
*/
readonly onUncaughtError?: (error: unknown) => void;
}
Members#
| Name | Type | Description |
|---|---|---|
renderId? |
readonly renderId?: string |
Prefix of every hydration key: letters, digits, _ and - only. Give each app rendered into the same page its own id, and pass the same id to hydrate(). |
head? |
readonly head?: ServerHead |
Collects the tags useHead, <Title>, <Meta>, ... register while rendering (see createServerHead). |
portals? |
readonly portals?: ServerPortals |
Collects the markup of the portals the render produces (see createServerPortals). Emit portals.html() at the end of <body> once the render is done. |
onCaughtError? |
readonly onCaughtError?: (error: unknown) => void |
Receives an error an ErrorBoundary of the render caught. The boundary's fallback is in the markup, so the caller can answer the request with the status of the error. Called once per caught error. For renderToStringAsync only the last pass is reported. |
onUncaughtError? |
readonly onUncaughtError?: (error: unknown) => void |
Receives an error no boundary took. With it the render does not throw that error and the markup lacks the part that failed. |