Skip to content

Runtime API

CAUTION

Experimental — not for production. Managed Data Mode SSR is available for evaluation and testing. Do not use it in production yet; the API and behaviour may change. In the meantime, continue using Webpack SSR.

Import browser-safe Managed Data Mode helpers from sku/runtime. Most helpers are documented on the topic pages that use them.

ExportUse for
defineServerEntry / defineClientEntryTyped server and client entry objects
createSkuContextsTyped useSite / useClientContext / useReactContext
SkuRouteObject / SiteOfType sites from getSite
usePreloadRouteWarm lazy route chunks on intent
useInsertHtmlQueue React nodes into the SSR response stream
getCspNonceRequest a CSP nonce for inline / injected scripts

useInsertHtml

Returns (callback: () => ReactNode) => void.

During document SSR, sku writes queued nodes into the response stream (first batch before </head>, then before later React chunks). In the browser it is a silent no-op.

Use it for streaming data transports such as Apollo’s buildManualDataTransport — see Apollo streaming hydration.

Injected script bodies carry the CSP nonce if enabled.

getCspNonce

Returns the request-scoped CSP nonce, minting one on first read. Call it only when you need a nonce for inline or injected scripts (for example Apollo extraScriptProps). In the browser it returns an empty string so isomorphic code can call it safely.

Express middleware can use req.getCspNonce() instead — same store for the response. See CSP.

See also