{"record":{"id":"83e8fd4fd244c7bc","repo":"vercel/next.js","slug":"route-workstore-route-used-unstable-navigation-83e8fd","errorCode":null,"errorMessage":"Route ${workStore.route} used `unstable_navigation()` inside `after()` while rendering. The `unstable_navigation()` function is used to indicate the subsequent code must only run during an actual navigation, but `after()` executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/after","messagePattern":"Route (.+?) used `unstable_navigation\\(\\)` inside `after\\(\\)` while rendering\\. The `unstable_navigation\\(\\)` function is used to indicate the subsequent code must only run during an actual navigation, but `after\\(\\)` executes after the request, so this function is not allowed in this scope\\. See more info here: https://nextjs\\.org/docs/app/api-reference/functions/after","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/request/cache-stages.ts","lineNumber":193,"sourceCode":" * Unlike `connection()`, it does not mark the subtree as request-dependent —\n * content below `await unstable_navigation()` remains fully cacheable.\n */\nexport function unstable_navigation(): Promise<void> {\n  const workStore = workAsyncStorage.getStore()\n  const workUnitStore = workUnitAsyncStorage.getStore()\n\n  if (!workStore || !workUnitStore) {\n    const callingExpression = 'unstable_navigation'\n    throwForMissingRequestStore(callingExpression)\n  }\n  if (!process.env.__NEXT_CACHE_COMPONENTS) {\n    throw new Error(\n      `Route ${workStore.route} used \\`unstable_navigation()\\`, which requires Cache Components to be enabled. Learn more: https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheComponents`\n    )\n  }\n\n  if (!isRequestApiAllowedInCurrentPhase(workUnitStore)) {\n    throw new Error(\n      `Route ${workStore.route} used \\`unstable_navigation()\\` inside \\`after()\\` while rendering. The \\`unstable_navigation()\\` function is used to indicate the subsequent code must only run during an actual navigation, but \\`after()\\` executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/after`\n    )\n  }\n\n  switch (workUnitStore.type) {\n    case 'prerender': {\n      // Static prerenders are computed once and shared across many\n      // clients, so there's no per-request prefetch cost to save by\n      // deferring the content — it's deliberately included in the static\n      // output (and thus in static prefetches).\n      // However, it's excluded from the shell, and has to be separated from\n      // unstable_prefetch(), so we have to delay it.\n      const { stagedRendering } = workUnitStore\n      if (!stagedRendering) {\n        // Prospective prerender\n        // `unstable_navigation()` will resolve in the final prerender, so resolve it here as well.\n        return Promise.resolve(undefined)\n      } else {","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/vercel/next.js/blob/258b1c1bc05f7099816b88f70b7b3422b24a4b8d/packages/next/src/server/request/cache-stages.ts#L175-L211","documentation":"Error \"Route ${workStore.route} used `unstable_navigation()` inside `after()` while rendering. The `unstable_navigation()` function is used to indicate the subsequent code must only run during an actual navigation, but `after()` executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/after\" thrown in vercel/next.js.","triggerScenarios":"Thrown at packages/next/src/server/request/cache-stages.ts:181 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move the unstable_navigation() call out of the after() callback so it runs during the request","Await unstable_navigation() before scheduling the after() work if ordering matters","Remove unstable_navigation() if the deferred work does not need navigation-stage semantics"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"258b1c1bc05f7099816b88f70b7b3422b24a4b8d","analyzedAt":"2026-08-21T19:56:13.433Z","contentChangedAt":"2026-08-21T19:56:13.433Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}