{"record":{"id":"10c8d16fde0f5c88","repo":"facebook/react","slug":"react-dom-server-is-not-supported-in-react-server","errorCode":null,"errorMessage":"react-dom/server is not supported in React Server Components.","messagePattern":"react-dom/server is not supported in React Server Components\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-dom/npm/server.react-server.js","lineNumber":3,"sourceCode":"'use strict';\n\nthrow new Error(\n  'react-dom/server is not supported in React Server Components.'\n);\n","sourceCodeStart":1,"sourceCodeEnd":6,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-dom/npm/server.react-server.js#L1-L6","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (app/page.server.js)\nimport {renderToString} from 'react-dom/server';\nexport default function Page() {\n  return <div dangerouslySetInnerHTML={{__html: renderToString(<Widget />)}} />;\n}\n\n// after (app/page.js — Server Component)\nimport Widget from './widget';\nexport default function Page() {\n  return <div><Widget /></div>;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Only attempt from plain server code, never from the RSC graph\ntry {\n  const {renderToString} = await import('react-dom/server');\n  return renderToString(tree);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('not supported in React Server Components')) {\n    throw new Error('react-dom/server cannot be used in the RSC graph — move this call to a plain server module');\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["react-server-components","react-dom","ssr","rendertostring","import-time-error"],"backgroundTag":"unsupported-import-in-rsc","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}