vercel/next.js · error · Error
`cacheTag()` is only available with the `cacheComponents` co
Error message
`cacheTag()` is only available with the `cacheComponents` config.
What it means
Guard in cacheTag() that fires when the function is called while the cacheComponents experiment is disabled (__NEXT_USE_CACHE is falsy). It is a config gate, not a runtime failure: the input at fault is the use of cacheTag() in a project whose next.config has not enabled cacheComponents.
Source
Thrown at packages/next/src/server/use-cache/cache-tag.ts:6
import { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.external'
import { validateTags } from '../lib/patch-fetch'
export function cacheTag(...tags: string[]): void {
if (!process.env.__NEXT_USE_CACHE) {
throw new Error(
'`cacheTag()` is only available with the `cacheComponents` config.'
)
}
const workUnitStore = workUnitAsyncStorage.getStore()
switch (workUnitStore?.type) {
case 'prerender':
case 'prerender-client':
case 'validation-client':
case 'prerender-runtime':
case 'prerender-legacy':
case 'request':
case 'unstable-cache':
case 'generate-static-params':
case undefined:
throw new Error(
'`cacheTag()` can only be called inside a "use cache" function.'View on GitHub (pinned to 0eb3775416)
Solutions
- Enable experimental.cacheComponents in next.config.js, or remove cacheTag() usage.
Defensive patterns
Strategy: validation
When it happens
Trigger: cacheTag() is called without the cacheComponents config enabled.
Common situations: Using cacheTag() in an app that has not enabled experimental cacheComponents.
AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19).
Data as JSON: /api/errors/0aacdecc1d16af41.
Report an issue: GitHub.