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 `${expression}`. 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 `${expression}`. 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/draft-mode.ts:208

      `Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis`
  )
}

function trackDynamicDraftMode(expression: string, constructorOpt: Function) {
  const workStore = workAsyncStorage.getStore()
  const workUnitStore = workUnitAsyncStorage.getStore()

  if (workStore) {
    // We have a store we want to track dynamic data access to ensure we
    // don't statically generate routes that manipulate draft mode.
    if (workUnitStore?.phase === 'after') {
      throw new Error(
        `Route ${workStore.route} used "${expression}" inside \`after()\`. The enabled status of \`draftMode()\` can be read inside \`after()\` but you cannot enable or disable \`draftMode()\`. See more info here: https://nextjs.org/docs/app/api-reference/functions/after`
      )
    }

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

    if (workUnitStore) {
      switch (workUnitStore.type) {
        case 'cache':
        case 'private-cache': {
          const error = createDraftModeMutationInUseCacheError(
            workStore.route,
            expression
          )
          Error.captureStackTrace(error, constructorOpt)
          applyOwnerStack(error)
          workStore.invalidDynamicUsageError ??= error
          throw error
        }
        case 'unstable-cache':

View on GitHub (pinned to 258b1c1bc0)

Solutions

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

Strategy: validation

When it happens

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

Common situations: A statically forced route accesses draftMode, which requires dynamic rendering.


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