close
Skip to content

Support more prefetch configuration options#92859

Merged
gnoff merged 1 commit intocanaryfrom
jstory/refine-prefetch
Apr 17, 2026
Merged

Support more prefetch configuration options#92859
gnoff merged 1 commit intocanaryfrom
jstory/refine-prefetch

Conversation

@gnoff
Copy link
Copy Markdown
Contributor

@gnoff gnoff commented Apr 15, 2026

"auto" mode is the default. It does not need to be explicitly exported "force-" modes suggest overriding framework heuristics "force-disabled" disables prefetching for this segment "force-static" forces any prefetching of this segment to be static "force-runtime" forces any prefetching of this segment to do runtime prefetching

It's worth noting that when runtime prefetching we fetch the necessary segment and all child segments in a single request. This means that a deeper segment might specify disabled or static and still get conditionally rendered as a runtime prefetch. This was already the behavior of runtime prefetching and not changing in this PR just something to call out since it may be confusing to folks trying to understand how the implementation of prefetching actually work

@gnoff gnoff requested a review from acdlite April 15, 2026 22:18
@nextjs-bot nextjs-bot added created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. tests type: next labels Apr 15, 2026
@@ -208,7 +217,7 @@ export function parseAppSegmentConfig(
}
case 'unstable_prefetch': {
return {
message: `Invalid unstable_prefetch value ${JSON.stringify(ctx.data)} on "${route}", must be "static" or "runtime".`,
message: `Invalid unstable_prefetch value ${JSON.stringify(ctx.data)} on "${route}", must be "auto", "disabled", "force-static", or "force-runtime".`,
Copy link
Copy Markdown
Contributor

@vercel vercel Bot Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message for invalid unstable_prefetch values says "disabled" instead of the correct valid enum value "force-disabled", misleading users into using a value that will also be rejected.

Fix on Vercel

@gnoff gnoff force-pushed the jstory/refine-prefetch branch from ffc9b22 to 75ff082 Compare April 15, 2026 22:25
@zhenyu-writer
Copy link
Copy Markdown

Thanks for the detailed proposal. The new prefetch modes make sense overall, especially the distinction between force-static, force-runtime, and force-disabled. One question I had while reading this: since "auto" remains the default and doesn’t need to be explicitly exported, do we want to document more clearly when users should prefer the force-* options over letting the framework heuristics decide? The note about runtime prefetch fetching the necessary segment plus all child segments in a single request is also helpful, but it may be worth calling out any tradeoffs there (for example request size vs. fewer round trips).

@gnoff gnoff force-pushed the jstory/refine-prefetch branch from 75ff082 to 6941cbb Compare April 15, 2026 22:34
@nextjs-bot
Copy link
Copy Markdown
Contributor

nextjs-bot commented Apr 15, 2026

Failing test suites

Commit: d510e7f | About building and testing Next.js

pnpm test-dev test/development/app-dir/instant-navs-devtools/instant-navs-devtools.test.ts (job)

  • instant-nav-panel > should show loading skeleton during SPA navigation after clicking Start (DD)
Expand output

● instant-nav-panel › should show loading skeleton during SPA navigation after clicking Start

expect(received).toBe(expected) // Object.is equality

Expected: true
Received: false

  164 |           '[data-testid="dynamic-skeleton"]'
  165 |         )
> 166 |         expect(skeleton).toBe(true)
      |                          ^
  167 |       },
  168 |       30000,
  169 |       500

  at toBe (development/app-dir/instant-navs-devtools/instant-navs-devtools.test.ts:166:26)
  at retry (lib/next-test-utils.ts:862:14)
  at Object.<anonymous> (development/app-dir/instant-navs-devtools/instant-navs-devtools.test.ts:161:5)

@gnoff gnoff force-pushed the jstory/refine-prefetch branch from 6941cbb to f899ae0 Compare April 15, 2026 22:54
@nextjs-bot
Copy link
Copy Markdown
Contributor

nextjs-bot commented Apr 15, 2026

Stats from current PR

✅ No significant changes detected

📊 All Metrics
📖 Metrics Glossary

Dev Server Metrics:

  • Listen = TCP port starts accepting connections
  • First Request = HTTP server returns successful response
  • Cold = Fresh build (no cache)
  • Warm = With cached build artifacts

Build Metrics:

  • Fresh = Clean build (no .next directory)
  • Cached = With existing .next directory

Change Thresholds:

  • Time: Changes < 50ms AND < 10%, OR < 2% are insignificant
  • Size: Changes < 1KB AND < 1% are insignificant
  • All other changes are flagged to catch regressions

⚡ Dev Server

Metric Canary PR Change Trend
Cold (Listen) 456ms 456ms ▁▁▁▁▁
Cold (Ready in log) 439ms 439ms ▁▁▂▁▂
Cold (First Request) 824ms 820ms █▁▁▁█
Warm (Listen) 456ms 456ms ▁▁▁▁▁
Warm (Ready in log) 439ms 440ms ▄▁▁▁▂
Warm (First Request) 335ms 339ms █▂▆▃▅
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change Trend
Cold (Listen) 455ms 456ms ▁▁▅▁▅
Cold (Ready in log) 448ms 447ms ▁▁▂▃▃
Cold (First Request) 2.061s 2.061s ▁▁▅▁▅
Warm (Listen) 457ms 456ms ▁▅▅▅▁
Warm (Ready in log) 446ms 447ms ▁▁▁▂▃
Warm (First Request) 2.063s 2.061s ▁▁▄▂▄

⚡ Production Builds

Metric Canary PR Change Trend
Fresh Build 4.031s 4.043s ▁▃▃▁▃
Cached Build 4.029s 4.057s ▁▂▃▁▁
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change Trend
Fresh Build 14.907s 14.903s ▁▁▁▃▃
Cached Build 15.028s 15.083s ▁▁▁▂▃
node_modules Size 494 MB 494 MB █▁█▁▁
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles
Canary PR Change
07rxhp_1_g4mu.js gzip 13.1 kB N/A -
08avva-dy02e7.js gzip 10.4 kB N/A -
0cz1d0mv5g_q7.js gzip 39.4 kB 39.4 kB
0fli3_wppnim5.js gzip 12.9 kB N/A -
0k09jwjeb-tki.js gzip 13.8 kB N/A -
0kb7_ep3r1z0_.js gzip 10.1 kB N/A -
0khj6l1dkbztz.js gzip 158 B N/A -
0kw8xgqdrilf6.js gzip 8.56 kB N/A -
0ojkk2e654xsc.js gzip 8.59 kB N/A -
0r13y5wryy_rb.js gzip 156 B N/A -
0wxpyd8r-vipl.js gzip 1.47 kB N/A -
0xy2fhla48_rd.js gzip 9.24 kB N/A -
10wqsvi2mgfmi.js gzip 9.82 kB N/A -
10x5yjviaxcoo.js gzip 155 B N/A -
16c9-6ahplfxj.js gzip 157 B N/A -
16lhqjoqbznyg.js gzip 220 B 220 B
16vepdkipri3r.js gzip 8.51 kB N/A -
17n96uu6y1pxq.js gzip 8.6 kB N/A -
18y4_8-9or0mn.js gzip 8.51 kB N/A -
1elt1qium-r2m.css gzip 115 B 115 B
1gq145j3kps-h.js gzip 8.62 kB N/A -
1nsh-mbn0e-se.js gzip 8.56 kB N/A -
1tsrrp1tdngti.js gzip 13.3 kB N/A -
2__-e_ym8n788.js gzip 450 B N/A -
22o6xd9_ywdu6.js gzip 233 B N/A -
25l6e629itu5j.js gzip 153 B N/A -
26ui6d5bv607a.js gzip 49.3 kB N/A -
27niq-zweblzs.js gzip 154 B N/A -
29bzq8qn1wyxo.js gzip 156 B N/A -
2jrge3u8y0nbz.js gzip 155 B N/A -
2kvj8yrfznmwx.js gzip 5.69 kB N/A -
2nrhepcp9ve2o.js gzip 70.8 kB N/A -
2qv7m7xjnokgr.js gzip 8.58 kB N/A -
2sewu64d_awot.js gzip 157 B N/A -
3_otef55yxm6_.js gzip 160 B N/A -
342ijzvrpe53h.js gzip 2.29 kB N/A -
3hiogkn179_b_.js gzip 169 B N/A -
3j78vioukb8ay.js gzip 156 B N/A -
3mm89bcl7qq09.js gzip 65.5 kB N/A -
3u73li4mpeclh.js gzip 157 B N/A -
44un3--wmqiyh.js gzip 7.61 kB N/A -
turbopack-0-..yjzq.js gzip 4.19 kB N/A -
turbopack-0h..4zvl.js gzip 4.19 kB N/A -
turbopack-0n..aaf6.js gzip 4.19 kB N/A -
turbopack-0u..8fol.js gzip 4.17 kB N/A -
turbopack-0x..iazv.js gzip 4.2 kB N/A -
turbopack-1x..5vxm.js gzip 4.19 kB N/A -
turbopack-2b..016f.js gzip 4.19 kB N/A -
turbopack-2h..-wl2.js gzip 4.19 kB N/A -
turbopack-2j..-y6j.js gzip 4.19 kB N/A -
turbopack-34..u2y9.js gzip 4.19 kB N/A -
turbopack-36..95b2.js gzip 4.19 kB N/A -
turbopack-3g..v35j.js gzip 4.19 kB N/A -
turbopack-3j..wswm.js gzip 4.19 kB N/A -
turbopack-3q..bf9c.js gzip 4.19 kB N/A -
00h4u194bb8c7.js gzip N/A 155 B -
06s2a1-sw8s8o.js gzip N/A 158 B -
0arkbdqpxc37i.js gzip N/A 8.6 kB -
0bz-xifewa17d.js gzip N/A 8.63 kB -
0em4a2sxerhz4.js gzip N/A 168 B -
0fbm505yboynb.js gzip N/A 49.3 kB -
0pmle13jdhdu0.js gzip N/A 65.5 kB -
0tvekitj587fh.js gzip N/A 8.51 kB -
0u3coesgskysq.js gzip N/A 161 B -
0yvk6-wi8e9wh.js gzip N/A 13.3 kB -
0z83a1om5rvtt.js gzip N/A 7.61 kB -
0zthaynjuxk58.js gzip N/A 157 B -
1-jqyfc89tixo.js gzip N/A 1.46 kB -
13q7l6-nygmmo.js gzip N/A 155 B -
14t1kneseb8th.js gzip N/A 2.3 kB -
15sb1-dsqfk_j.js gzip N/A 8.59 kB -
19mzuj3yh9is8.js gzip N/A 70.8 kB -
1ab2xruymo-oj.js gzip N/A 449 B -
1fx2d-glwbnlk.js gzip N/A 155 B -
1h55541zppmdw.js gzip N/A 156 B -
1tu25qtsmfhar.js gzip N/A 9.82 kB -
1vein_gnv3mwr.js gzip N/A 8.56 kB -
1wzrm0xjjbzn5.js gzip N/A 10.1 kB -
1z3g0uaqtv9_3.js gzip N/A 8.56 kB -
25a1yz7zua29z.js gzip N/A 13.8 kB -
2bi5hx402juv-.js gzip N/A 8.58 kB -
2hy56297fog9u.js gzip N/A 8.52 kB -
2u_rpxq3tzytl.js gzip N/A 233 B -
2wyls4kpqcn48.js gzip N/A 155 B -
3-a4k89t_92ej.js gzip N/A 153 B -
368lim5wq0o0r.js gzip N/A 12.9 kB -
3dj55jtmtuus3.js gzip N/A 155 B -
3drqjohogojbw.js gzip N/A 5.69 kB -
3g8l1m2-o-ewi.js gzip N/A 13.1 kB -
3jmkxsnxg0nrh.js gzip N/A 10.4 kB -
3v_4mi6gvc1jd.js gzip N/A 152 B -
3wpp8nvyoj121.js gzip N/A 9.24 kB -
42eqqiw5x99_v.js gzip N/A 158 B -
turbopack-0g..siep.js gzip N/A 4.19 kB -
turbopack-0n..58uq.js gzip N/A 4.19 kB -
turbopack-16..ev3s.js gzip N/A 4.19 kB -
turbopack-18..3_jf.js gzip N/A 4.19 kB -
turbopack-1d..i_fs.js gzip N/A 4.21 kB -
turbopack-1e..4m2e.js gzip N/A 4.19 kB -
turbopack-1e..tlsj.js gzip N/A 4.19 kB -
turbopack-1g..nrg9.js gzip N/A 4.19 kB -
turbopack-2a..b-mj.js gzip N/A 4.19 kB -
turbopack-2s.._bhv.js gzip N/A 4.19 kB -
turbopack-2y..bi9m.js gzip N/A 4.17 kB -
turbopack-32..dufm.js gzip N/A 4.19 kB -
turbopack-3b..a3aj.js gzip N/A 4.19 kB -
turbopack-3i..xnar.js gzip N/A 4.19 kB -
Total 465 kB 465 kB ⚠️ +12 B

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 719 B 718 B
Total 719 B 718 B ✅ -1 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 433 B 436 B
Total 433 B 436 B ⚠️ +3 B

📦 Webpack

Client

Main Bundles
Canary PR Change
2637-HASH.js gzip 4.63 kB N/A -
7724.HASH.js gzip 169 B N/A -
8274-HASH.js gzip 61.4 kB N/A -
8817-HASH.js gzip 5.59 kB N/A -
c3500254-HASH.js gzip 62.8 kB N/A -
framework-HASH.js gzip 59.7 kB 59.7 kB
main-app-HASH.js gzip 254 B 254 B
main-HASH.js gzip 39.4 kB 39.3 kB
webpack-HASH.js gzip 1.68 kB 1.68 kB
5887-HASH.js gzip N/A 5.61 kB -
6522-HASH.js gzip N/A 60.8 kB -
6779-HASH.js gzip N/A 4.63 kB -
8854.HASH.js gzip N/A 169 B -
eab920f9-HASH.js gzip N/A 62.8 kB -
Total 236 kB 235 kB ✅ -645 B
Polyfills
Canary PR Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Total 39.4 kB 39.4 kB
Pages
Canary PR Change
_app-HASH.js gzip 193 B 193 B
_error-HASH.js gzip 182 B 182 B
css-HASH.js gzip 333 B 334 B
dynamic-HASH.js gzip 1.81 kB 1.8 kB
edge-ssr-HASH.js gzip 255 B 255 B
head-HASH.js gzip 353 B 349 B 🟢 4 B (-1%)
hooks-HASH.js gzip 384 B 382 B
image-HASH.js gzip 581 B 581 B
index-HASH.js gzip 260 B 259 B
link-HASH.js gzip 2.51 kB 2.51 kB
routerDirect..HASH.js gzip 316 B 318 B
script-HASH.js gzip 386 B 386 B
withRouter-HASH.js gzip 313 B 314 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Total 7.98 kB 7.97 kB ✅ -10 B

Server

Edge SSR
Canary PR Change
edge-ssr.js gzip 126 kB 126 kB
page.js gzip 273 kB 273 kB
Total 399 kB 399 kB ✅ -389 B
Middleware
Canary PR Change
middleware-b..fest.js gzip 617 B 617 B
middleware-r..fest.js gzip 156 B 156 B
middleware.js gzip 44.3 kB 44.3 kB
edge-runtime..pack.js gzip 842 B 842 B
Total 46 kB 45.9 kB ✅ -74 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 721 B 720 B
Total 721 B 720 B ✅ -1 B
Build Cache
Canary PR Change
0.pack gzip 4.39 MB 4.38 MB 🟢 6.83 kB (0%)
index.pack gzip 114 kB 112 kB 🟢 2.37 kB (-2%)
index.pack.old gzip 113 kB 114 kB
Total 4.61 MB 4.6 MB ✅ -8.31 kB

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 347 kB 347 kB
app-page-exp..prod.js gzip 192 kB 192 kB
app-page-tur...dev.js gzip 346 kB 346 kB
app-page-tur..prod.js gzip 192 kB 192 kB
app-page-tur...dev.js gzip 343 kB 343 kB
app-page-tur..prod.js gzip 190 kB 190 kB
app-page.run...dev.js gzip 343 kB 343 kB
app-page.run..prod.js gzip 190 kB 190 kB
app-route-ex...dev.js gzip 77 kB 77 kB
app-route-ex..prod.js gzip 52.5 kB 52.5 kB
app-route-tu...dev.js gzip 77.1 kB 77.1 kB
app-route-tu..prod.js gzip 52.6 kB 52.6 kB
app-route-tu...dev.js gzip 76.7 kB 76.7 kB
app-route-tu..prod.js gzip 52.3 kB 52.3 kB
app-route.ru...dev.js gzip 76.6 kB 76.6 kB
app-route.ru..prod.js gzip 52.3 kB 52.3 kB
dist_client_...dev.js gzip 324 B 324 B
dist_client_...dev.js gzip 326 B 326 B
dist_client_...dev.js gzip 318 B 318 B
dist_client_...dev.js gzip 317 B 317 B
pages-api-tu...dev.js gzip 43.9 kB 43.9 kB
pages-api-tu..prod.js gzip 33.5 kB 33.5 kB
pages-api.ru...dev.js gzip 43.9 kB 43.9 kB
pages-api.ru..prod.js gzip 33.5 kB 33.5 kB
pages-turbo....dev.js gzip 53.3 kB 53.3 kB
pages-turbo...prod.js gzip 39.1 kB 39.1 kB
pages.runtim...dev.js gzip 53.3 kB 53.3 kB
pages.runtim..prod.js gzip 39.1 kB 39.1 kB
server.runti..prod.js gzip 63 kB 63 kB
Total 3.06 MB 3.06 MB ⚠️ +48 B
📝 Changed Files (8 files)

Files with changes:

  • app-page-exp..ntime.dev.js
  • app-page-exp..time.prod.js
  • app-page-tur..ntime.dev.js
  • app-page-tur..time.prod.js
  • app-page-tur..ntime.dev.js
  • app-page-tur..time.prod.js
  • app-page.runtime.dev.js
  • app-page.runtime.prod.js
View diffs
app-page-exp..ntime.dev.js
failed to diff
app-page-exp..time.prod.js

Diff too large to display

app-page-tur..ntime.dev.js
failed to diff
app-page-tur..time.prod.js

Diff too large to display

app-page-tur..ntime.dev.js
failed to diff
app-page-tur..time.prod.js

Diff too large to display

app-page.runtime.dev.js
failed to diff
app-page.runtime.prod.js

Diff too large to display

📎 Tarball URL
https://vercel-packages.vercel.app/next/commits/d510e7f5ee5d12beea3f97d0cb67f5c553536c55/next

"auto" mode is the default. It does not need to be explicitly exported
"force-" modes suggest overriding framework heuristics
"force-disabled" disables prefetching for this segment
"force-static" forces any prefetching of this segment to be static
"force-runtime" forces any prefetching of this segment to do runtime prefetching

It's worth noting that when runtime prefetching we fetch the necessary segment and all child segments in a single request. This means that a deeper segment might specify disabled or static and still get conditionally rendered as a runtime prefetch. This was already the behavior of runtime prefetching and not changing in this PR just something to call out since it may be confusing to folks trying to understand how the implementation of prefetching actually works
@gnoff gnoff force-pushed the jstory/refine-prefetch branch from f899ae0 to d510e7f Compare April 17, 2026 15:10
@gnoff gnoff merged commit a7d1573 into canary Apr 17, 2026
488 of 494 checks passed
@gnoff gnoff deleted the jstory/refine-prefetch branch April 17, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. tests type: next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants