{"record":{"id":"25d92af49ee7f2bb","repo":"vercel/next.js","slug":"route-workstore-route-used-unstable-prefetch","errorCode":null,"errorMessage":"Route ${workStore.route} used `unstable_prefetch()`, which requires Cache Components to be enabled. Learn more: https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheComponents","messagePattern":"Route (.+?) used `unstable_prefetch\\(\\)`, which requires Cache Components to be enabled\\. Learn more: https://nextjs\\.org/docs/app/api-reference/config/next-config-js/cacheComponents","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/request/cache-stages.ts","lineNumber":37,"sourceCode":" * a prefetch (i.e. when using `<Link prefetch={true}>`) or a navigation.\n *\n * It has no effect during static prerendering — static output is computed\n * once and shared across many clients, so there's no per-request cost to\n * save — and no effect on the initial load of a page.\n *\n * Unlike `connection()`, it does not mark the subtree as request-dependent —\n * content below `await unstable_prefetch()` remains fully cacheable.\n */\nexport function unstable_prefetch(): Promise<void> {\n  const workStore = workAsyncStorage.getStore()\n  const workUnitStore = workUnitAsyncStorage.getStore()\n\n  if (!workStore || !workUnitStore) {\n    const callingExpression = 'unstable_prefetch'\n    throwForMissingRequestStore(callingExpression)\n  }\n  if (!process.env.__NEXT_CACHE_COMPONENTS) {\n    throw new Error(\n      `Route ${workStore.route} used \\`unstable_prefetch()\\`, 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_prefetch()\\` inside \\`after()\\` while rendering. The \\`unstable_prefetch()\\` function is used to indicate the subsequent code must not run in the app shell, 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      // Content below `prefetch()` is excluded from the shell, but it's\n      // deliberately included in the static output (and thus in static\n      // prefetches), so we only delay it until the static prefetch stage.\n      const { stagedRendering } = workUnitStore\n      if (!stagedRendering) {\n        // Prospective prerender","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/vercel/next.js/blob/258b1c1bc05f7099816b88f70b7b3422b24a4b8d/packages/next/src/server/request/cache-stages.ts#L19-L55","documentation":"Error \"Route ${workStore.route} used `unstable_prefetch()`, which requires Cache Components to be enabled. Learn more: https://nextjs.org/docs/app/api-reference/config/next-config-js/cacheComponents\" thrown in vercel/next.js.","triggerScenarios":"Thrown at packages/next/src/server/request/cache-stages.ts:36 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Enable Cache Components by setting experimental.cacheComponents: true in next.config.js (the __NEXT_CACHE_COMPONENTS flag this guard checks)","Remove the unstable_prefetch() call from the route","If you only need to defer work out of the app shell, check whether the cacheComponents-less alternative connection() fits, or upgrade to a configuration that supports prefetching"],"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"}