Перейти к содержанию

renderToStringAsync

renderToStringAsync

1
2
3
4
5
6
7
8
function renderToStringAsync<T>(
  fn: () => T,
  options?: {
    timeoutMs?: number;
    renderId?: string;
    nonce?: string;
  }
): Promise<string>;

Same as renderToString except 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.

1
const html = await renderToStringAsync(App);

Options

Name Type Description
timeoutMs number The number of milliseconds to wait for a <Suspense> boundary to resolve before timing out.
renderId string The id to use for the render.
nonce string The nonce to use for the script tag.

Комментарии