HydrationScript
generateHydrationScript as a component, for a document rendered with server JSX: <HydrationScript nonce={nonce} /> in the <head>.
generateHydrationScript as a component, for a document rendered with server JSX:
<HydrationScript nonce={nonce} /> in the <head>.
Import#
ts
import { HydrationScript } from "@shadow-js/web/server";
Signature#
ts
function HydrationScript(props: HydrationScriptOptions = {}): unknown
Parameters#
| Name | Description |
|---|---|
props |
The CSP nonce and the event types to capture. Undefined uses the defaults of HydrationScriptOptions. |
Returns#
The script as trusted raw markup.
Examples#
ts
import { createComponent, HydrationScript, renderToString } from "@shadow-js/web/server";
function Document() {
return (
<html>
<head>
<HydrationScript nonce="r4nd0m" />
</head>
<body>Hello</body>
</html>
);
}
const html = renderToString(() => createComponent(Document, {}));