vercel/next.js · error

Circular structure in "getInitialProps" result of page "${__

Error message

Circular structure in "getInitialProps" result of page "${__NEXT_DATA__.page}". https://nextjs.org/docs/messages/circular-structure

What it means

getInlineScriptSource stringifies the page's __NEXT_DATA__ inside a try/catch; when JSON.stringify fails because the getInitialProps return value contains a circular reference, the catch block rethrows this error — data inlined into __NEXT_DATA__ must be JSON-serializable.

Source

Thrown at packages/next/src/pages/_document.tsx:896

        }

        console.warn(
          `Warning: data for page "${__NEXT_DATA__.page}"${
            __NEXT_DATA__.page === context.dangerousAsPath
              ? ''
              : ` (path "${context.dangerousAsPath}")`
          } is ${prettyBytes(
            bytes
          )} which exceeds the threshold of ${prettyBytes(
            largePageDataBytes
          )}, this amount of data can reduce performance.\nSee more info here: https://nextjs.org/docs/messages/large-page-data`
        )
      }

      return htmlEscapeJsonString(data)
    } catch (err) {
      if (isError(err) && err.message.indexOf('circular structure') !== -1) {
        throw new Error(
          `Circular structure in "getInitialProps" result of page "${__NEXT_DATA__.page}". https://nextjs.org/docs/messages/circular-structure`
        )
      }
      throw err
    }
  }

  render() {
    const {
      assetPrefix,
      buildManifest,
      unstable_runtimeJS,
      docComponentsRendered,
      assetQueryString,
      disableOptimizedLoading,
      crossOrigin,
    } = this.context
    const disableRuntimeJS = unstable_runtimeJS === false

View on GitHub (pinned to 0eb3775416)

Solutions

  1. Remove circular references from the object returned by getInitialProps; it must be JSON-serializable.
  2. Use a serializer-safe subset of the data (e.g. strip class instances, DOM nodes, or back-references) before returning props.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/next/src/pages/_document.tsx:896 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/209d34d7f8926370. Report an issue: GitHub.