vercel/next.js · error · Error

Route ${workStore.route} used ${apiName} inside `unstable_ca

Error message

Route ${workStore.route} used ${apiName} inside `unstable_cache`. This is not supported. Use `"use cache"` instead.

What it means

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.

Source

Thrown at packages/next/src/server/request/root-params.ts:56

      // 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)
      return Promise.resolve(workUnitStore.rootParams[paramName])
    }
    case 'prerender':
    case 'prerender-legacy': {
      return createPrerenderRootParamPromise(
        paramName,
        workStore,
        workUnitStore,

View on GitHub (pinned to 0eb3775416)

Solutions

  1. Use "use cache" instead of unstable_cache when accessing root params.
Defensive patterns

Strategy: validation

When it happens

Trigger: A root-params API is called inside unstable_cache.

Common situations: Using root params inside an unstable_cache function instead of 'use cache'.


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/d3ed8c715240f705. Report an issue: GitHub.