vercel/next.js · error · Error
${apiName} was used inside a Server Action. This is not supp
Error message
${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. What it means
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.
Source
Thrown at packages/next/src/server/request/root-params.ts:48
throw new Error(
`Route ${workStore.route} used ${apiName} outside of a Server Component. This is not allowed.`
)
}
const actionStore = actionAsyncStorage.getStore()
if (actionStore) {
if (actionStore.isAppRoute) {
// TODO(root-params): add support for route handlers
throw new Error(
`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.`
)
}
if (actionStore.isAction && workUnitStore.phase === 'action') {
// Actions are not fundamentally tied to a route (even if they're always submitted from some page),
// so root params would be inconsistent if an action is called from multiple roots.
// Make sure we check if the phase is "action" - we should not error in the rerender
// after an action revalidates or updates cookies (which will still have `actionStore.isAction === true`)
throw new Error(
`${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.`
)
}
}
switch (workUnitStore.type) {
case 'unstable-cache': {
throw new Error(
`Route ${workStore.route} used ${apiName} inside \`unstable_cache\`. This is not supported. Use \`"use cache"\` instead.`
)
}
case 'cache': {
if (!workUnitStore.rootParams) {
throw new Error(
`Route ${workStore.route} used ${apiName} inside \`"use cache"\` nested within \`unstable_cache\`. Root params are not available in this context.`
)
}
workUnitStore.readRootParamNames.add(paramName)View on GitHub (pinned to 0eb3775416)
Solutions
- Do not call next/root-params functions inside Server Actions; pass the values as arguments.
Defensive patterns
Strategy: validation
When it happens
Trigger: A root-params API is called inside a Server Action.
Common situations: Using next/root-params within a 'use server' function, which lacks route context.
AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19).
Data as JSON: /api/errors/be0f304ebc29e4e7.
Report an issue: GitHub.