AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Router.Refresh() Eagerly Refetches In-Viewport Link Prefetches In Next.Js V16 Causing Massive ISR Write Amplification

Next.js v16 changes router.refresh() to immediately refetch all in-viewport prefetched <Link> entries, whereas v15 only marked them stale and waited for user intent. Each refetch results in a Vercel ISR write, causing daily ISR writes to increase from 7.1M to 358.5M (~50x) and peak up to 1.52B (~200x).

highConfidence 92%Next.jsAffected V16.2.4Affected V16.3.0-Canary.2

Origin Analysis

Next.js v16's client-side router reducer now treats prefetch cache invalidation on router.refresh() as an eager revalidation by default, actively refetching every in-viewport prefetched route segment instead of lazily marking entries as stale. This is an undocumented behavioral change likely introduced during the per-segment prefetching refactor and lacks an opt-out configuration.
1. Build and start the v16 app with `next build && next start` (or use the deployed Vercel instance). 2. Open the controller page and separate /blog tabs; scroll blog so several post <Link>s are in viewport and prefetched. 3. Open DevTools Network, filter prefetch requests, add x-vercel-cache column. 4. Click 'Call revalidateTag()' on controller; it broadcasts router.refresh() to blog tabs. 5. Observe that every in-viewport <Link> immediately fires new prefetch requests with x-vercel-cache: REVALIDATED, unlike v15 where no extra prefetches occur.

Fixing Code Block

Edge Case Audit

This workaround disables automatic viewport prefetching, which may increase navigation latency, especially on mobile or slow connections. Manual prefetch on hover/touch may still generate requests, though far fewer than viewport-based eager refetch. The API for router.prefetch and Link props may change in future Next.js versions; test thoroughly after upgrades. Rolling back this change restores the original eager behavior, so monitor ISR writes and navigation metrics before and after.

Ecosystem Topology