smolter
API

Scripts

Emit the initial hydration payload and browser module entry.

Compatibility

ReactAvailable in this renderer's browser integration.
React SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.
PreactAvailable in this renderer's browser integration.
Preact SSRAvailable to this renderer's SSR integration; browser event handlers run after hydration.

Import from @kasperrt/smolter/preact/document @kasperrt/smolter/react/document

Signature

function Scripts({ nonce }: ScriptProps): import("preact").JSX.Element;

Parameters

Accepts ScriptProps with an optional nonce. Requires application context containing the router, root data, and optional entry URL.

Returns

Renders an inline bootstrap script from the configured application entryScript, then an application/json script with id smolter-data containing { root, snapshot }. If entry is present, also renders a type="module" script with that URL. The nonce is applied to all emitted scripts.

Example

Render Scripts once near the end of the root document body. Use the server-provided deployed entry URL through renderApplication or the application integration.

import { Scripts } from "@kasperrt/smolter/preact/document";

export function BrowserBootstrap() {
  return <Scripts />;
}

Hydration contract

The payload is captured once for this mounted document and does not change after navigation or revalidation. It describes the initial SSR view. Error name and message are preserved with enumerable error fields; non-enumerable stack and cause are not copied. serializeData escapes characters that could break a script element. The application owns what data it makes available to the browser.

View implementation ↗