Skip to content

Support unstable_prefetch route segment config #849

@github-actions

Description

@github-actions

Next.js Change

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

Commit: vercel/next.js@ac6d993
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    nextjs-trackingTracking issue for a Next.js canary change relevant to vinext

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions