{"record":{"id":"0aacdecc1d16af41","repo":"vercel/next.js","slug":"cachetag-is-only-available-with-the-cachecomp","errorCode":null,"errorMessage":"`cacheTag()` is only available with the `cacheComponents` config.","messagePattern":"`cacheTag\\(\\)` is only available with the `cacheComponents` config\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/use-cache/cache-tag.ts","lineNumber":6,"sourceCode":"import { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.external'\nimport { validateTags } from '../lib/patch-fetch'\n\nexport function cacheTag(...tags: string[]): void {\n  if (!process.env.__NEXT_USE_CACHE) {\n    throw new Error(\n      '`cacheTag()` is only available with the `cacheComponents` config.'\n    )\n  }\n\n  const workUnitStore = workUnitAsyncStorage.getStore()\n\n  switch (workUnitStore?.type) {\n    case 'prerender':\n    case 'prerender-client':\n    case 'validation-client':\n    case 'prerender-runtime':\n    case 'prerender-legacy':\n    case 'request':\n    case 'unstable-cache':\n    case 'generate-static-params':\n    case undefined:\n      throw new Error(\n        '`cacheTag()` can only be called inside a \"use cache\" function.'","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/server/use-cache/cache-tag.ts#L1-L24","documentation":"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.","triggerScenarios":"cacheTag() is called without the cacheComponents config enabled.","commonSituations":"Using cacheTag() in an app that has not enabled experimental cacheComponents.","solutions":["Enable experimental.cacheComponents in next.config.js, or remove cacheTag() usage."],"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"}