mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
In #95064 we added a global opt-in to the runtime stage of Cached Navigations: setting `cachedNavigations: 'allow-runtime'` makes every route runtime-cache, on top of the existing per-segment `prefetch = 'allow-runtime'`. This extends the opt-in: a `prefetch` config of `'partial'`, `'unstable_eager'`, or `'allow-runtime'` all enable Partial Prefetching for a route, and a route already doing PPR-style partial prefetching should also runtime-cache its navigations. The next-config `partialPrefetching`, which enables Partial Prefetching globally, opts every route in as well. Both runtime-prefetch spawn gates in `app-render.tsx` now broaden their condition to include `partialPrefetching` and any segment `prefetch` that enables Partial Prefetching, via a new `anySegmentHasPartialPrefetchingEnabled` helper. The narrower callers that gate metadata staging and the dev reveal stage keep using `anySegmentHasRuntimePrefetchEnabled`, since they specifically concern routes the client runtime-prefetches (`'allow-runtime'`), not partial ones. Because `partialPrefetching` has no default and is not auto-enabled by `cacheComponents`, apps that do not set it are unaffected. Tests add `prefetch = 'partial'` and `prefetch = 'unstable_eager'` routes to the existing `default` fixture and a new `partial-prefetching` fixture for the global config, each asserting the route runtime-caches its request-derived content on a second navigation without a per-segment `prefetch = 'allow-runtime'` export.
21 lines
653 B
TypeScript
21 lines
653 B
TypeScript
import type { NextConfig } from 'next'
|
|
|
|
const nextConfig: NextConfig = {
|
|
cacheComponents: true,
|
|
productionBrowserSourceMaps: true,
|
|
// Enabling Partial Prefetching globally opts every route into runtime Cached
|
|
// Navigations, even without a per-segment `prefetch` config.
|
|
// `cachedNavigations` is left at its default (`true`, the static stage), so
|
|
// the runtime stage here comes solely from `partialPrefetching`.
|
|
partialPrefetching: true,
|
|
experimental: {
|
|
prefetchInlining: false,
|
|
exposeTestingApiInProductionBuild: true,
|
|
optimisticRouting: true,
|
|
useOffline: true,
|
|
varyParams: true,
|
|
},
|
|
}
|
|
|
|
export default nextConfig
|