{"record":{"id":"8460b5308e0bf13f","repo":"vercel/next.js","slug":"route-workstore-route-used-cookies-inside","errorCode":null,"errorMessage":"Route ${workStore.route} used `cookies()` inside `after()` while rendering. This is not supported. If you need this data inside an `after()` callback, use `cookies()` outside of the callback. See more info here: https://nextjs.org/docs/app/api-reference/functions/after","messagePattern":"Route (.+?) used `cookies\\(\\)` inside `after\\(\\)` while rendering\\. This is not supported\\. If you need this data inside an `after\\(\\)` callback, use `cookies\\(\\)` outside of the callback\\. See more info here: https://nextjs\\.org/docs/app/api-reference/functions/after","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/request/cookies.ts","lineNumber":43,"sourceCode":"  RENDER_STAGES_BY_DATA_KIND,\n} from '../dynamic-rendering-utils'\nimport { createDedupedByCallsiteServerErrorLoggerDev } from '../create-deduped-by-callsite-server-error-logger'\nimport { isRequestApiAllowedInCurrentPhase } from './utils'\nimport { applyOwnerStack } from '../dynamic-rendering-utils'\nimport { InvariantError } from '../../shared/lib/invariant-error'\nimport {\n  createCookiesInUseCacheError,\n  createCookiesInUnstableCacheError,\n} from '../use-cache/use-cache-messages'\n\nexport function cookies(): Promise<ReadonlyRequestCookies> {\n  const callingExpression = 'cookies'\n  const workStore = workAsyncStorage.getStore()\n  const workUnitStore = workUnitAsyncStorage.getStore()\n\n  if (workStore) {\n    if (workUnitStore && !isRequestApiAllowedInCurrentPhase(workUnitStore)) {\n      throw new Error(\n        `Route ${workStore.route} used \\`cookies()\\` inside \\`after()\\` while rendering. This is not supported. If you need this data inside an \\`after()\\` callback, use \\`cookies()\\` outside of the callback. See more info here: https://nextjs.org/docs/app/api-reference/functions/after`\n      )\n    }\n\n    if (workStore.forceStatic) {\n      // When using forceStatic we override all other logic and always just return an empty\n      // cookies object without tracking\n      const underlyingCookies = createEmptyCookies()\n      return makeUntrackedCookies(underlyingCookies)\n    }\n\n    if (workStore.dynamicShouldError) {\n      throw new StaticGenBailoutError(\n        `Route ${workStore.route} with \\`dynamic = \"error\"\\` couldn't be rendered statically because it used \\`cookies()\\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`\n      )\n    }\n\n    if (workUnitStore) {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/vercel/next.js/blob/258b1c1bc05f7099816b88f70b7b3422b24a4b8d/packages/next/src/server/request/cookies.ts#L25-L61","documentation":"Error \"Route ${workStore.route} used `cookies()` inside `after()` while rendering. This is not supported. If you need this data inside an `after()` callback, use `cookies()` outside of the callback. See more info here: https://nextjs.org/docs/app/api-reference/functions/after\" thrown in vercel/next.js.","triggerScenarios":"cookies() is called inside an after() callback during render.","commonSituations":"Reading cookies inside unstable_after; read them outside and pass values in.","solutions":["Read cookies() before scheduling after(), and pass the values into the callback closure."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"258b1c1bc05f7099816b88f70b7b3422b24a4b8d","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}