A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://18.react.dev/reference/react-dom/server/renderToNodeStream below:

renderToNodeStream – React

renderToNodeStream renders a React tree to a Node.js Readable Stream.

const stream = renderToNodeStream(reactNode, options?)

Reference renderToNodeStream(reactNode, options?)

On the server, call renderToNodeStream to get a Node.js Readable Stream which you can pipe into the response.

import { renderToNodeStream } from 'react-dom/server';

const stream = renderToNodeStream(<App />);

stream.pipe(response);

On the client, call hydrateRoot to make the server-generated HTML interactive.

See more examples below.

Parameters Returns

A Node.js Readable Stream that outputs an HTML string.

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

Call renderToNodeStream to get a Node.js Readable Stream which you can pipe to your server response:

import { renderToNodeStream } from 'react-dom/server';

// The route handler syntax depends on your backend framework

app.use('/', (request, response) => {

const stream = renderToNodeStream(<App />);

stream.pipe(response);

});

The stream will produce the initial non-interactive HTML output of your React components. On the client, you will need to call hydrateRoot to hydrate that server-generated HTML and make it interactive.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4