vercel/next.js · error · Error

cache: 'no-store' used on fetch for ${fetchUrl} with 'export

Error message

cache: 'no-store' used on fetch for ${fetchUrl} with 'export const fetchCache = 'only-cache'

What it means

Thrown by patch-fetch when a fetch() inside a route uses cache:'no-store' while the route declares `export const fetchCache = 'only-cache'`. The only-cache mode forbids uncached fetches, so the combination is contradictory and surfaces as a configuration error.

Source

Thrown at packages/next/src/server/lib/patch-fetch.ts:716

          case 'force-no-store': {
            cacheReason = 'fetchCache = force-no-store'
            break
          }
          case 'only-no-store': {
            if (
              currentFetchCacheConfig === 'force-cache' ||
              (typeof finalRevalidate !== 'undefined' && finalRevalidate > 0)
            ) {
              throw new Error(
                `cache: 'force-cache' used on fetch for ${fetchUrl} with 'export const fetchCache = 'only-no-store'`
              )
            }
            cacheReason = 'fetchCache = only-no-store'
            break
          }
          case 'only-cache': {
            if (currentFetchCacheConfig === 'no-store') {
              throw new Error(
                `cache: 'no-store' used on fetch for ${fetchUrl} with 'export const fetchCache = 'only-cache'`
              )
            }
            break
          }
          case 'force-cache': {
            if (
              typeof currentFetchRevalidate === 'undefined' ||
              currentFetchRevalidate === 0
            ) {
              cacheReason = 'fetchCache = force-cache'
              finalRevalidate = INFINITE_CACHE
            }
            break
          }
          case 'default-cache':
          case 'default-no-store':
          case 'auto':

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Change the conflicting fetch to { cache: 'force-cache' } or a positive revalidate to match the only-cache policy.
  2. Or change/remove `export const fetchCache = 'only-cache'` if you need that fetch to stay dynamic.
  3. Audit every fetch in the route so none use no-store.

Example fix

// before
export const fetchCache = 'only-cache'
export default async function Page() {
  const res = await fetch('https://api/x', { cache: 'no-store' }) // throws
}

// after
export const fetchCache = 'only-cache'
export default async function Page() {
  const res = await fetch('https://api/x', { cache: 'force-cache' })
}
Defensive patterns

Strategy: validation

Validate before calling

// If fetchCache = 'only-cache', no fetch may use cache: 'no-store'

Type guard

function fetchCacheAllowsNoStore(mode: string): boolean {
  return mode !== 'only-cache'
}

Try / catch

null

Prevention

When it happens

Trigger: A route file has `export const fetchCache = 'only-cache'` and inside it calls fetch(url, { cache: 'no-store' }). patch-fetch detects the conflict.

Common situations: Setting fetchCache='only-cache' to force caching but leaving a fetch that explicitly disables caching, or copying a dynamic fetch into a route that mandates caching.

Related errors


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