{"record":{"id":"49a7babce90756e8","repo":"vercel/next.js","slug":"route-workstore-route-used-apiname-inside-a","errorCode":null,"errorMessage":"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.","messagePattern":"Route (.+?) used (.+?) inside a Route Handler\\. Support for this API in Route Handlers is planned for a future version of Next\\.js\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/request/root-params.ts","lineNumber":39,"sourceCode":"  const apiName = `\\`import('next/root-params').${paramName}()\\``\n\n  const workStore = workAsyncStorage.getStore()\n  if (!workStore) {\n    throw new InvariantError(`Missing workStore in ${apiName}`)\n  }\n\n  const workUnitStore = workUnitAsyncStorage.getStore()\n  if (!workUnitStore) {\n    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.`","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/server/request/root-params.ts#L21-L57","documentation":"Scope check in getRootParam: the call happened inside a Route Handler (actionStore.isAppRoute). Root params are derived from the route tree during component rendering and are not yet wired into the app-route execution path, so accessing them there is a documented not-yet-supported error rather than a crash.","triggerScenarios":"A root-params API is called inside a Route Handler.","commonSituations":"Using next/root-params inside route.ts, which is not yet supported.","solutions":["Do not use next/root-params in Route Handlers; read params from the handler context instead."],"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"}