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.
| Export | Use for |
|---|---|
defineServerEntry / defineClientEntry | Typed server and client entry objects |
createSkuContexts | Typed useSite / useClientContext / useReactContext |
SkuRouteObject / SiteOf | Type sites from getSite |
usePreloadRoute | Warm lazy route chunks on intent |
useInsertHtml | Queue React nodes into the SSR response stream |
getCspNonce | Request 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
- Request entries —
defineServerEntry/defineClientEntry - Providers —
createSkuContexts - Routing —
usePreloadRoute - Data loading — Apollo +
useInsertHtml - CSP — headers and nonces
