{"record":{"id":"d3ed8c715240f705","repo":"vercel/next.js","slug":"route-workstore-route-used-apiname-inside-u","errorCode":null,"errorMessage":"Route ${workStore.route} used ${apiName} inside `unstable_cache`. This is not supported. Use `\"use cache\"` instead.","messagePattern":"Route (.+?) used (.+?) inside `unstable_cache`\\. This is not supported\\. Use `\"use cache\"` instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/request/root-params.ts","lineNumber":56,"sourceCode":"      // TODO(root-params): add support for route handlers\n      throw new Error(\n        `Route ${workStore.route} used ${apiName} inside a Route Handler. Support for this API in Route Handlers is planned for a future version of Next.js.`\n      )\n    }\n    if (actionStore.isAction && workUnitStore.phase === 'action') {\n      // Actions are not fundamentally tied to a route (even if they're always submitted from some page),\n      // so root params would be inconsistent if an action is called from multiple roots.\n      // Make sure we check if the phase is \"action\" - we should not error in the rerender\n      // after an action revalidates or updates cookies (which will still have `actionStore.isAction === true`)\n      throw new Error(\n        `${apiName} was used inside a Server Action. This is not supported. Functions from 'next/root-params' can only be called in the context of a route.`\n      )\n    }\n  }\n\n  switch (workUnitStore.type) {\n    case 'unstable-cache': {\n      throw new Error(\n        `Route ${workStore.route} used ${apiName} inside \\`unstable_cache\\`. This is not supported. Use \\`\"use cache\"\\` instead.`\n      )\n    }\n    case 'cache': {\n      if (!workUnitStore.rootParams) {\n        throw new Error(\n          `Route ${workStore.route} used ${apiName} inside \\`\"use cache\"\\` nested within \\`unstable_cache\\`. Root params are not available in this context.`\n        )\n      }\n      workUnitStore.readRootParamNames.add(paramName)\n      return Promise.resolve(workUnitStore.rootParams[paramName])\n    }\n    case 'prerender':\n    case 'prerender-legacy': {\n      return createPrerenderRootParamPromise(\n        paramName,\n        workStore,\n        workUnitStore,","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/server/request/root-params.ts#L38-L74","documentation":"Scope check in getRootParam: the accessor was invoked inside a function wrapped with unstable_cache. Closures capture their dynamic scope at cache time, so root params inside unstable_cache would be frozen to the first request's values; the cacheComponents-era \"use cache\" directive is the supported alternative.","triggerScenarios":"A root-params API is called inside unstable_cache.","commonSituations":"Using root params inside an unstable_cache function instead of 'use cache'.","solutions":["Use \"use cache\" instead of unstable_cache when accessing root params."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}