vercel/next.js · error · SerializableError

Error serializing ` ` returned from ` ` in " ". Reason…

Error message

Error serializing `${path}` returned from `${method}` in "${page}".
Reason: `undefined` cannot be serialized as JSON. Please use `null` or omit this value.

What it means

Serialization check in isSerializable while walking props returned from getStaticProps/getServerSideProps: the value at this path is undefined, which JSON serialization drops entirely. Because the page would render with a missing prop rather than fail loudly, Next.js rejects it and asks for null or omission instead.

Solutions

  1. Replace undefined with null or omit the property from the returned props.
Defensive patterns

Strategy: validation

When it happens

Trigger: Props contain an undefined value at a serialized path.

Common situations: A field left undefined in getStaticProps/getServerSideProps props; use null or omit it instead.


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

Appendix: source

Thrown at packages/next/src/lib/is-serializable-props.ts:71

  ): true {
    const type = typeof value
    if (
      // `null` can be serialized, but not `undefined`.
      value === null ||
      // n.b. `bigint`, `function`, `symbol`, and `undefined` cannot be
      // serialized.
      //
      // `object` is special-cased below, as it may represent `null`, an Array,
      // a plain object, a class, et al.
      type === 'boolean' ||
      type === 'number' ||
      type === 'string'
    ) {
      return true
    }

    if (type === 'undefined') {
      throw new SerializableError(
        page,
        method,
        path,
        '`undefined` cannot be serialized as JSON. Please use `null` or omit this value.'
      )
    }

    if (isPlainObject(value)) {
      visit(refs, value, path)

      if (
        Object.entries(value).every(([key, nestedValue]) => {
          const nextPath = regexpPlainIdentifier.test(key)
            ? `${path}.${key}`
            : `${path}[${JSON.stringify(key)}]`

          const newRefs = new Map(refs)
          return (

View on GitHub (pinned to 0eb3775416)