Rendering

renderToStringAsync

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

Same as renderToString except that it will wait for all <Suspense> boundaries to resolve before returning the results. Resource data is automatically serialized into the script tag and will be hydrated on client load.

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

const html = await renderToStringAsync(App)

Options

NameTypeDescription
timeoutMsnumberThe number of milliseconds to wait for a <Suspense> boundary to resolve before timing out.
renderIdstringThe id to use for the render.
noncestringThe nonce to use for the script tag.
Report an issue with this page