facebook/react · error · Error
react-dom/server is not supported in React Server Components
Error message
react-dom/server is not supported in React Server Components.
What it means
react-dom/server exposes the legacy/Fizz SSR renderers (renderToString, renderToPipeableStream), but it is incompatible with the React Server Components runtime: under the react-server condition it resolves to a stub that throws on import. Inside an RSC graph, SSR is driven by the framework's own pipeline (react-server-dom-* entry points), so user code must not import react-dom/server there.
Source
Thrown at packages/react-dom/npm/server.react-server.js:3
'use strict'; throw new Error( 'react-dom/server is not supported in React Server Components.' );
View on GitHub (pinned to eafeac097b)
Solutions
- Remove the react-dom/server import from Server Component files and let the framework's SSR pipeline render the page
- Move string/HTML rendering into plain server code (a route handler or script) that resolves the normal server condition
- For static prerendering in RSC apps, use the framework's designated prerender entry instead of react-dom/server inside the RSC graph
- Restructure the component to pass children instead of injecting server-rendered HTML strings
Example fix
// before (app/page.server.js)
import {renderToString} from 'react-dom/server';
export default function Page() {
return <div dangerouslySetInnerHTML={{__html: renderToString(<Widget />)}} />;
}
// after (app/page.js — Server Component)
import Widget from './widget';
export default function Page() {
return <div><Widget /></div>;
} Defensive patterns
Strategy: try-catch
Try / catch
// Only attempt from plain server code, never from the RSC graph
try {
const {renderToString} = await import('react-dom/server');
return renderToString(tree);
} catch (e) {
if (e instanceof Error && e.message.includes('not supported in React Server Components')) {
throw new Error('react-dom/server cannot be used in the RSC graph — move this call to a plain server module');
}
throw e;
} Prevention
- Keep SSR helpers in plain server modules (route handlers, scripts) outside the react-server condition
- Never call renderToString inside Server Components; render children instead
- Use framework-provided SSR pipelines instead of manual react-dom/server calls in RSC apps
When it happens
Trigger: importing 'react-dom/server' (or react-dom/server.node, server.edge) from a Server Component or any module in the react-server condition graph, e.g. calling renderToString() inside a Server Component to inline-render markup.
Common situations: Porting an SSR page to an App Router while keeping old renderToString helpers; a shared isomorphic utility that string-renders via react-dom/server being imported by both graphs; test setups resolving the react-server condition for all server-side files.
Related errors
- react-dom/profiling is not supported in React Server Compone
- react-dom/static is not supported in React Server Components
- react-dom/unstable_testing is not supported in React Server
- 426
- 417
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/10c8d16fde0f5c88.
Report an issue: GitHub.