{"record":{"id":"be0f304ebc29e4e7","repo":"vercel/next.js","slug":"apiname-was-used-inside-a-server-action-this-i","errorCode":null,"errorMessage":"${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.","messagePattern":"(.+?) 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\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/request/root-params.ts","lineNumber":48,"sourceCode":"    throw new Error(\n      `Route ${workStore.route} used ${apiName} outside of a Server Component. This is not allowed.`\n    )\n  }\n\n  const actionStore = actionAsyncStorage.getStore()\n  if (actionStore) {\n    if (actionStore.isAppRoute) {\n      // 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)","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/server/request/root-params.ts#L30-L66","documentation":"Scope check in getRootParam: the accessor ran during the action phase of a Server Action. Actions are not bound to a single route (one action can be submitted from multiple roots), so root params would be ambiguous there and the call is rejected during that phase only — rerenders after revalidation still pass.","triggerScenarios":"A root-params API is called inside a Server Action.","commonSituations":"Using next/root-params within a 'use server' function, which lacks route context.","solutions":["Do not call next/root-params functions inside Server Actions; pass the values as arguments."],"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"}