vercel/next.js · error · StaticGenBailoutError

Route ${workStore.route} with `dynamic = "error"` couldn't b

Error message

Route ${workStore.route} with `dynamic = "error"` couldn't be rendered statically because it used `headers()`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering

What it means

Error "Route ${workStore.route} with `dynamic = "error"` couldn't be rendered statically because it used `headers()`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering" thrown in vercel/next.js.

Source

Thrown at packages/next/src/server/request/headers.ts:91

        case 'generate-static-params':
          throw new Error(
            `Route ${workStore.route} used \`headers()\` inside \`generateStaticParams\`. This is not supported because \`generateStaticParams\` runs at build time without an HTTP request. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context`
          )
        case 'prerender':
        case 'prerender-client':
        case 'validation-client':
        case 'private-cache':
        case 'prerender-runtime':
        case 'prerender-legacy':
        case 'request':
          break
        default:
          workUnitStore satisfies never
      }
    }

    if (workStore.dynamicShouldError) {
      throw new StaticGenBailoutError(
        `Route ${workStore.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`headers()\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`
      )
    }

    if (workUnitStore) {
      switch (workUnitStore.type) {
        case 'prerender':
          return makeHangingHeaders(workStore, workUnitStore)
        case 'prerender-client':
        case 'validation-client':
          const exportName = '`headers`'
          throw new InvariantError(
            `${exportName} must not be used within a client component. Next.js should be preventing ${exportName} from being included in client components statically, but did not in this case.`
          )
        case 'prerender-legacy':
          // Legacy Prerender
          // We are in a legacy static generation mode while prerendering
          // We track dynamic access here so we don't need to wrap the headers in

View on GitHub (pinned to 258b1c1bc0)

Solutions

  1. Remove dynamic = "error" or stop using headers() in the route.
Defensive patterns

Strategy: validation

When it happens

Trigger: headers() is used in a route with dynamic = "error".

Common situations: A statically forced route reads headers, which requires dynamic rendering.


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