Function: resolveHtmlStream()

Estimated reading time: less than 1 minute
function resolveHtmlStream(template, requestData): Readable

Joins the html base template (with possible suspense's fallbacks) with the request data and returns the final Readable to be piped into the response stream.

This API is meant to be used by library authors and should not be used directly.

Parameters

template

Element

The initial HTML template, possibly containing suspense fallbacks.

requestData

RequestData

The request data containing the stream to write resolved content into.

Returns

Readable

The same stream or a new one with the template prepended.

Example

const html = <RootLayout rid={rid} />
const requestData = SUSPENSE_ROOT.requests.get(rid)

if (!requestData) {
  return html
}

// This prepends the html into the stream, handling possible
// cases where the html resolved after one of its async children
return resolveHtmlStream(html, requestData)

See

renderToStream