{"record":{"id":"deaa3f392acfa459","repo":"vercel/next.js","slug":"experimental-usecache-cannot-be-disabled-when-c","errorCode":null,"errorMessage":"`experimental.useCache` cannot be disabled when `cacheComponents` is enabled, because Cache Components relies on the `\"use cache\"` directive. Please remove it from ${configFileName}.","messagePattern":"`experimental\\.useCache` cannot be disabled when `cacheComponents` is enabled, because Cache Components relies on the `\"use cache\"` directive\\. Please remove it from (.+?)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":1616,"sourceCode":"    process.env.__NEXT_EXPERIMENTAL_MCP_SERVER === 'true'\n  ) {\n    result.experimental.mcpServer = true\n  }\n\n  if (result.cacheComponents) {\n    // TODO: remove once we've finished migrating internally to cacheComponents.\n    result.experimental.ppr = true\n  }\n\n  // `experimental.useCache` is deprecated in favor of the top-level\n  // `cacheComponents` option. A defined value means the user set the option\n  // explicitly, because it's only backfilled from `cacheComponents` below.\n  if (result.experimental.useCache !== undefined) {\n    // Disabling the directive that Cache Components is built around leaves the\n    // app in a state where every `\"use cache\"` fails to compile with an error\n    // that asks for the already-enabled `cacheComponents` option.\n    if (!result.experimental.useCache && result.cacheComponents) {\n      throw new Error(\n        `\\`experimental.useCache\\` cannot be disabled when \\`cacheComponents\\` is enabled, because Cache Components relies on the \\`\"use cache\"\\` directive. Please remove it from ${configFileName}.`\n      )\n    }\n\n    if (!silent) {\n      if (result.cacheComponents) {\n        Log.warnOnce(\n          `\\`experimental.useCache\\` is no longer needed, because \\`cacheComponents\\` already enables the \\`\"use cache\"\\` directive. You can remove it from ${configFileName}.`\n        )\n      } else {\n        Log.warnOnce(\n          `\\`experimental.useCache\\` is deprecated. Please use the top-level \\`cacheComponents\\` option instead in ${configFileName}.`\n        )\n      }\n    }\n  }\n\n  // \"use cache\" was originally implicitly enabled with the cacheComponents flag, so","sourceCodeStart":1598,"sourceCodeEnd":1634,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L1598-L1634","documentation":"Thrown at config.ts:1615 when `experimental.useCache` is explicitly set to a falsy value (`false`) while the top-level `cacheComponents` option is enabled. Cache Components internally relies on the `\"use cache\"` directive, so disabling `useCache` would leave every cached function uncompilable. The fix is to remove the `experimental.useCache` override.","triggerScenarios":"`{ cacheComponents: true, experimental: { useCache: false } }`; setting `useCache: false` explicitly while opting into Cache Components.","commonSituations":"Carrying over an old `useCache: false` from when the feature was experimental; toggling flags independently without realizing the dependency; partial migration to `cacheComponents`.","solutions":["Remove the `experimental.useCache` line from your config — `cacheComponents: true` enables the directive for you.","If you genuinely do not want Cache Components, set `cacheComponents: false` instead of disabling `useCache`."],"exampleFix":"// before\nmodule.exports = { cacheComponents: true, experimental: { useCache: false } }\n// after\nmodule.exports = { cacheComponents: true }","handlingStrategy":"validation","validationCode":"if (config.cacheComponents && config.experimental?.useCache === false) {\n  throw new Error('Remove experimental.useCache when cacheComponents is enabled');\n}","typeGuard":"function consistentCacheFlags(c: any): boolean {\n  return !(c.cacheComponents === true && c.experimental?.useCache === false);\n}","tryCatchPattern":null,"preventionTips":["When enabling `cacheComponents`, remove legacy `experimental.useCache`.","Treat the two flags as mutually exclusive in code review."],"tags":["config","cache-components","experimental","migration"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}