vercel/next.js · error · Error

"${getDisplayName(Document)}.getInitialProps()" should resol

Error message

"${getDisplayName(Document)}.getInitialProps()" should resolve to an object with a "html" prop set with a valid html string

What it means

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.

Source

Thrown at packages/next/src/server/render.tsx:1345

        const stream = await renderShell(EnhancedApp, EnhancedComponent)
        await stream.allReady
        const html = await streamToString(stream)

        return { html, head }
      }
      const documentCtx = { ...ctx, renderPage }
      const docProps: DocumentInitialProps = await loadGetInitialProps(
        Document,
        documentCtx
      )
      // the response might be finished on the getInitialProps call
      if (isResSent(res) && !isSSG) return null

      if (!docProps || typeof docProps.html !== 'string') {
        const message = `"${getDisplayName(
          Document
        )}.getInitialProps()" should resolve to an object with a "html" prop set with a valid html string`
        throw new Error(message)
      }

      return { docProps, documentCtx }
    }

    const renderContent = (_App: AppType, _Component: NextComponentType) => {
      const EnhancedApp = _App || App
      const EnhancedComponent = _Component || Component

      return ctx.err && ErrorDebug ? (
        <Body>
          <ErrorDebug />
        </Body>
      ) : (
        <Body>
          <AppContainerWithIsomorphicFiberStructure>
            {renderPageTree(EnhancedApp, EnhancedComponent, {
              ...props,

View on GitHub (pinned to 89d017eac4)

Solutions

  1. Ensure Document's `getInitialProps` resolves to an object containing an `html` string prop.
  2. If you call `renderPage`, return its result spread into your returned object.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/next/src/server/render.tsx:1347 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of vercel/next.js@89d017eac4 (2026-08-19). Data as JSON: /api/errors/d2d3a34a4f19d770. Report an issue: GitHub.