renderToStaticNodeStream


Reference

renderToStaticNodeStream(reactNode, options?)

On the server, call renderToStaticNodeStream to get a .

The stream will produce non-interactive HTML output of your React components.

Parameters

  • reactNode: A React node you want to render to HTML. For example, a JSX element like <Page />.

  • optional options: An object for server render.

    • optional identifierPrefix: A string prefix React uses for IDs generated by Useful to avoid conflicts when using multiple roots on the same page.

Returns

A that outputs an HTML string. The resulting HTML can’t be hydrated on the client.

Caveats

  • renderToStaticNodeStream output cannot be hydrated.

  • This method will wait for all to complete before returning any output.

  • As of React 18, this method buffers all of its output, so it doesn’t actually provide any benefits.

  • The returned stream is a byte stream encoded in utf-8. If you need a stream in another encoding, take a look at a project like , which provides transform streams for transcoding text.


Usage

Rendering a React tree as static HTML to a Node.js Readable Stream

Call renderToStaticNodeStream to get a which you can pipe to your server response:

The stream will produce the initial non-interactive HTML output of your React components.