ReactDOMServer

// ES modules
import ReactDOMServer from 'react-dom/server';
// CommonJS
var ReactDOMServer = require('react-dom/server');

The ReactDOMServer object enables you to render components to static markup, typically, it’s used on a Node server.

renderToString()

You can use this method to generate HTML on the server and send the markup down on the initial request for faster page loads and to allow search engines to crawl your pages for SEO purposes.

ReactDOMServer.renderToString(element)

Render a React element to its initial HTML, react will return an HTML string.

renderToStaticMarkup()

ReactDOMServer.renderToStaticMarkup(element)

Similar to renderToString, except this doesn’t create extra DOM attributes that React uses internally, such as data-reactroot.

This is useful if you want to use React as a simple static page generator, as stripping away the extra attributes can save some bytes.

renderToNodeStream()

You can use this method to generate HTML on the server and send the markup down on the initial request for faster page loads and to allow search engines to crawl your pages for SEO purposes.

ReactDOMServer.renderToNodeStream(element)

Render a React element to its initial HTML. Returns a Readable stream that outputs an HTML string. The HTML output by this stream is exactly equal to what ReactDOMServer.renderToString would return.

Server-only. This API is not available in the browser.

renderToStaticNodeStream()

This is useful if you want to use React as a simple static page generator, as stripping away the extra attributes can save some bytes.

ReactDOMServer.renderToStaticNodeStream(element)

Similar to renderToNodeStream, except this doesn’t create extra DOM attributes that React uses internally, such as data-reactroot.

ReactDOMServer — Structure map

Clickable & Draggable!

ReactDOMServer — Related pages: