Server-rendered static pages
Generate static HTML for a server response.
React 19+ · Function
Renders a non-interactive React tree to an HTML string, typically on the server. Its output cannot be hydrated, so use it for static markup rather than interactive applications.
Call this server API with a React node to synchronously produce an HTML string. The result is intended for non-interactive output, so it cannot later be hydrated; for interactive server-rendered applications, use streaming or the renderToString and hydrateRoot combination instead.
const html = renderToStaticMarkup(reactNode, options?)| Name | Type | Description |
|---|---|---|
reactNode | ReactNode | A React node to render as HTML, such as a JSX element like <Page />. |
options | object | Optional server-rendering options. The documented option is identifierPrefix, a string prefix for IDs generated by useId. |
An HTML string.
import { renderToStaticMarkup } from 'react-dom/server';
function Page() {
return <main><h1>About</h1><p>Static content.</p></main>;
}
const html = renderToStaticMarkup(<Page />);
console.log(html);Renders a non-interactive page component into an HTML string for a server response or other static output.
Generate static HTML for a server response.
Produce markup for content that does not need client-side React behavior.
Render multiple roots while preventing useId collisions.
renderToStringhydrateRootuseIdrenderToPipeableStreamrenderToReadableStream