[GH-ISSUE #849] Support unstable_prefetch route segment config #184

Open
opened 2026-05-06 12:37:57 +02:00 by BreizhHardware · 1 comment

Originally created by @github-actions[bot] on GitHub (Apr 15, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/849

Next.js Change

Next.js added a new unstable_prefetch route segment config option, decoupled from unstable_instant.

Commit: github.com/vercel/next.js@ac6d9932a6
PR: #92754

What Changed

A new route segment config export unstable_prefetch was added to App Router pages/layouts:

export const unstable_prefetch = 'runtime' // or 'static'

Key details:

  • Type: 'static' | 'runtime''static' is a no-op (default), 'runtime' enables runtime prefetching
  • Requires cacheComponents: true in next.config.js — throws a build error otherwise
  • Server Components only — throws a build error if used in a "use client" module
  • Decoupled from unstable_instant — previously, runtime prefetching was configured via unstable_instant: { prefetch: 'runtime' }. Now unstable_prefetch controls prefetching independently, and unstable_instant is purely for instant validation
  • The create-component-tree.tsx now reads unstable_prefetch instead of unstable_instant.prefetch to determine hasRuntimePrefetch

Impact on vinext

vinext's route segment config parsing (routing/app-router.ts, get-page-static-info equivalent) should recognize unstable_prefetch as a valid export to avoid spurious warnings. The actual runtime prefetching behavior is not something vinext needs to implement immediately (it's experimental and tied to cacheComponents), but the config should be parsed and acknowledged.

Files Changed (non-test)

  • packages/next/src/build/segment-config/app/app-segment-config.ts — added PrefetchSchema, Prefetch type, and unstable_prefetch to the schema
  • packages/next/src/build/analysis/get-page-static-info.ts — added validation (requires cacheComponents, disallows "use client")
  • packages/next/src/server/app-render/create-component-tree.tsx — reads unstable_prefetch instead of unstable_instant.prefetch
  • crates/next-core/src/segment_config.rs — Turbopack-side parsing of the new config
Originally created by @github-actions[bot] on GitHub (Apr 15, 2026). Original GitHub issue: https://github.com/cloudflare/vinext/issues/849 ## Next.js Change Next.js added a new `unstable_prefetch` route segment config option, decoupled from `unstable_instant`. **Commit:** https://github.com/vercel/next.js/commit/ac6d9932a64aa1f927c5dda2f70a39da4dc777fd **PR:** [#92754](https://github.com/vercel/next.js/pull/92754) ## What Changed A new route segment config export `unstable_prefetch` was added to App Router pages/layouts: ```ts export const unstable_prefetch = 'runtime' // or 'static' ``` Key details: - **Type:** `'static' | 'runtime'` — `'static'` is a no-op (default), `'runtime'` enables runtime prefetching - **Requires `cacheComponents: true`** in `next.config.js` — throws a build error otherwise - **Server Components only** — throws a build error if used in a `"use client"` module - **Decoupled from `unstable_instant`** — previously, runtime prefetching was configured via `unstable_instant: { prefetch: 'runtime' }`. Now `unstable_prefetch` controls prefetching independently, and `unstable_instant` is purely for instant validation - The `create-component-tree.tsx` now reads `unstable_prefetch` instead of `unstable_instant.prefetch` to determine `hasRuntimePrefetch` ## Impact on vinext vinext's route segment config parsing (`routing/app-router.ts`, `get-page-static-info` equivalent) should recognize `unstable_prefetch` as a valid export to avoid spurious warnings. The actual runtime prefetching behavior is not something vinext needs to implement immediately (it's experimental and tied to `cacheComponents`), but the config should be parsed and acknowledged. ## Files Changed (non-test) - `packages/next/src/build/segment-config/app/app-segment-config.ts` — added `PrefetchSchema`, `Prefetch` type, and `unstable_prefetch` to the schema - `packages/next/src/build/analysis/get-page-static-info.ts` — added validation (requires `cacheComponents`, disallows `"use client"`) - `packages/next/src/server/app-render/create-component-tree.tsx` — reads `unstable_prefetch` instead of `unstable_instant.prefetch` - `crates/next-core/src/segment_config.rs` — Turbopack-side parsing of the new config
Author
Owner

@github-actions[bot] commented on GitHub (Apr 18, 2026):

Update from Next.js canary (2026-04-17):

Two commits changed the unstable_prefetch segment config API:

  1. a7d1573 — Support more prefetch configuration options: The valid values changed from 'static' | 'runtime' to 'auto' | 'force-disabled' | 'force-static' | 'force-runtime'. The PrefetchDisabled hint moved from instant === false to prefetch === 'force-disabled'. 'auto' is the default and does not need to be explicitly exported.

  2. 1931877 — Remove prefetch from instant config: The prefetch property was removed from the instant export type. Prefetching is now controlled exclusively via the prefetch export.

When implementing this, the Prefetch type should use the new values, and the segment config parser needs to validate against 'auto' | 'force-disabled' | 'force-static' | 'force-runtime'.

<!-- gh-comment-id:4273210300 --> @github-actions[bot] commented on GitHub (Apr 18, 2026): **Update from Next.js canary (2026-04-17):** Two commits changed the `unstable_prefetch` segment config API: 1. **[`a7d1573`](https://github.com/vercel/next.js/commit/a7d15733919f38bc6fe2aa8164955fbbf509c980) — Support more prefetch configuration options**: The valid values changed from `'static' | 'runtime'` to `'auto' | 'force-disabled' | 'force-static' | 'force-runtime'`. The `PrefetchDisabled` hint moved from `instant === false` to `prefetch === 'force-disabled'`. `'auto'` is the default and does not need to be explicitly exported. 2. **[`1931877`](https://github.com/vercel/next.js/commit/1931877c29570715ebf4ff33629a81b32723a8ad) — Remove prefetch from instant config**: The `prefetch` property was removed from the `instant` export type. Prefetching is now controlled exclusively via the `prefetch` export. When implementing this, the `Prefetch` type should use the new values, and the segment config parser needs to validate against `'auto' | 'force-disabled' | 'force-static' | 'force-runtime'`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#184
No description provided.