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. Until then, continue using Webpack SSR.

Import browser-safe Managed Data Mode helpers from sku/runtime. Topic pages that use these helpers document most of 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. Do not use it for Document head tags. 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 undefined so isomorphic code can call it safely.

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

See also ​