{"record":{"id":"d2d3a34a4f19d770","repo":"vercel/next.js","slug":"getdisplayname-document-getinitialprops-sh","errorCode":null,"errorMessage":"\"${getDisplayName(Document)}.getInitialProps()\" should resolve to an object with a \"html\" prop set with a valid html string","messagePattern":"\"(.+?)\\.getInitialProps\\(\\)\" should resolve to an object with a \"html\" prop set with a valid html string","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/render.tsx","lineNumber":1345,"sourceCode":"        const stream = await renderShell(EnhancedApp, EnhancedComponent)\n        await stream.allReady\n        const html = await streamToString(stream)\n\n        return { html, head }\n      }\n      const documentCtx = { ...ctx, renderPage }\n      const docProps: DocumentInitialProps = await loadGetInitialProps(\n        Document,\n        documentCtx\n      )\n      // the response might be finished on the getInitialProps call\n      if (isResSent(res) && !isSSG) return null\n\n      if (!docProps || typeof docProps.html !== 'string') {\n        const message = `\"${getDisplayName(\n          Document\n        )}.getInitialProps()\" should resolve to an object with a \"html\" prop set with a valid html string`\n        throw new Error(message)\n      }\n\n      return { docProps, documentCtx }\n    }\n\n    const renderContent = (_App: AppType, _Component: NextComponentType) => {\n      const EnhancedApp = _App || App\n      const EnhancedComponent = _Component || Component\n\n      return ctx.err && ErrorDebug ? (\n        <Body>\n          <ErrorDebug />\n        </Body>\n      ) : (\n        <Body>\n          <AppContainerWithIsomorphicFiberStructure>\n            {renderPageTree(EnhancedApp, EnhancedComponent, {\n              ...props,","sourceCodeStart":1327,"sourceCodeEnd":1363,"githubUrl":"https://github.com/vercel/next.js/blob/89d017eac43ebf4742ed2b58d3c1373b70283b69/packages/next/src/server/render.tsx#L1327-L1363","documentation":"Validation of the custom Document's getInitialProps result in renderToHTMLImpl: docProps is falsy or its html property is not a string. Document.getInitialProps must call renderPage and return an object with the resulting html string; anything else (missing return, forgotten renderPage) cannot be used to produce the document, so it throws naming the Document component.","triggerScenarios":"Thrown at packages/next/src/server/render.tsx:1347 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure Document's `getInitialProps` resolves to an object containing an `html` string prop.","If you call `renderPage`, return its result spread into your returned object."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"89d017eac43ebf4742ed2b58d3c1373b70283b69","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}