Rendering

renderToString

Edit this page
import { renderToString } from "solid-js/web"
function renderToString<T>(
fn: () => T,
options?: {
nonce?: string
renderId?: string
}
): string

Renders to a string synchronously. The function also generates a script tag for progressive hydration. Options include eventNames to listen to before the page loads and play back on hydration, and nonce to put on the script tag.

renderId is used to namespace renders when having multiple top level roots.

const html = renderToString(App)

Options

NameTypeDescription
noncestringThe nonce to use for the script tag.
renderIdstringThe id to use for the script tag.
Report an issue with this page