{"record":{"id":"25e4a7e4e8588208","repo":"vercel/next.js","slug":"route-workstore-route-used-apiname-inside","errorCode":null,"errorMessage":"Route ${workStore.route} used ${apiName} inside `\"use cache\"` nested within `unstable_cache`. Root params are not available in this context.","messagePattern":"Route (.+?) used (.+?) inside `\"use cache\"` nested within `unstable_cache`\\. Root params are not available in this context\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/request/root-params.ts","lineNumber":62,"sourceCode":"      // 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,\n        apiName\n      )\n    }\n    case 'validation-client':\n    case 'prerender-client': {\n      throw new InvariantError(","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/server/request/root-params.ts#L44-L80","documentation":"Nested-scope check in getRootParam: the accessor ran inside a \"use cache\" function that is itself nested within unstable_cache. Even the use-cache scope cannot rescue root params there, because the outer unstable_cache boundary still fixes the captured scope; the combination is explicitly unsupported.","triggerScenarios":"A root-params API is used in 'use cache' nested in unstable_cache.","commonSituations":"Root params unavailable inside a 'use cache' scope nested within unstable_cache.","solutions":["Do not nest \"use cache\" inside unstable_cache when reading root params; restructure the caching."],"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-14T00:17:10.932Z"}