{"record":{"id":"6dded0c0f17adb64","repo":"facebook/react","slug":"the-body-tag-may-only-be-rendered-once","errorCode":null,"errorMessage":"The `<body>` tag may only be rendered once.","messagePattern":"The `<body>` tag may only be rendered once\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js","lineNumber":3774,"sourceCode":"    // This <head> is deep and is likely just an error. we emit it inline though.\n    // Validation should warn that this tag is the the wrong spot.\n    return pushStartGenericElement(target, props, 'head', formatContext);\n  }\n}\n\nfunction pushStartBody(\n  target: Array<Chunk | PrecomputedChunk>,\n  props: Object,\n  renderState: RenderState,\n  preambleState: null | PreambleState,\n  formatContext: FormatContext,\n): ReactNodeList {\n  if (formatContext.insertionMode < HTML_MODE) {\n    // This <body> is the Document.body\n    const preamble = preambleState || renderState.preamble;\n\n    if (preamble.bodyChunks) {\n      throw new Error(`The ${'`<body>`'} tag may only be rendered once.`);\n    }\n\n    // Insert a marker in the body where the contribution to the body tag was in case we need to clear it.\n    if (preambleState !== null) {\n      target.push(bodyPreambleContributionChunk);\n    }\n\n    preamble.bodyChunks = [];\n    return pushStartSingletonElement(\n      preamble.bodyChunks,\n      props,\n      'body',\n      formatContext,\n    );\n  } else {\n    // This <head> is deep and is likely just an error. we emit it inline though.\n    // Validation should warn that this tag is the the wrong spot.\n    return pushStartGenericElement(target, props, 'body', formatContext);","sourceCodeStart":3756,"sourceCodeEnd":3792,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js#L3756-L3792","documentation":"Thrown by pushStartBody when a second document-level <body> begins rendering (preamble.bodyChunks already populated and insertionMode < HTML_MODE). HTML permits exactly one body element; the first <body> claims the preamble slot and any later one aborts the render.","triggerScenarios":"A tree containing two <body> elements at document level — e.g. <html><head/><body>...</body></html> in the layout plus another <body> rendered by a page, a portal target markup string, or an imported legacy component.","commonSituations":"Merging an existing full HTML page component into an app that already provides <html>/<body>; copy-pasting standalone page templates (with their own <body>) into framework layouts; third-party widgets shipping full-document markup.","solutions":["Keep <body> only in the root layout and render everything else as fragments or regular elements","Convert pasted full-page components: strip their <html>/<head>/<body> wrappers down to the inner content","Grep the render output/tree for '<body' to find the duplicate source"],"exampleFix":"// before: page.jsx renders its own document\n<body><h1>Hi</h1></body>\n\n// after: layout owns the body; page renders content only\n<> <h1>Hi</h1> </>","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep exactly one <body>, defined in the root layout","Strip full-document wrappers from pasted page components","Add a lint rule (e.g. react/forbid-elements or custom) banning <body>/<html> outside a designated layout file"],"tags":["ssr","body","preamble","document-structure"],"backgroundTag":"duplicate-document-element","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}