cloudflare / cloudflare/vinext

Support `partialPrefetching` global config and `unstable_prefetch = 'partial'` segment opt-in

Open
#1,819 0 comments 0 reactions 0 assignees View on GitHub
nextjs-tracking
Dominant language
TypeScript
Stars
8.8k
Forks
406
Avg merge
2d 6h
Merged PRs (30d)
120

Description

## Next.js Change

**Commit:** [`f5af284`](https://github.com/vercel/next.js/commit/f5af284527d86fc1542f802bbf56fe3875fafd33)
**PR:** [#94448](https://github.com/vercel/next.js/pull/94448)

## What changed

Adds a new global config option `partialPrefetching` and a new value `'partial'` for the per-segment `unstable_prefetch` config. Both control the behavior of ``.

When Partial Prefetching is enabled, only Cache Components are included in a prefetch response — dynamic data is omitted. This applies the Partial Prerendering idea to client navigations.

### Configuration surface

```ts
// next.config.js — global opt-in
module.exports = {
partialPrefetching: true, // also 'unstable_eager' for migration mode
}
```

```ts
// app//page.tsx — per-segment opt-in
export const unstable_prefetch = 'partial' // also 'static' (default), 'runtime', 'unstable_eager'
```

The accepted `unstable_prefetch` values are now: `'static' | 'runtime' | 'partial' | 'unstable_eager'`. `'partial'` enables Partial Prefetching for the segment; `'unstable_eager'` forces every `` to that segment to behave as if `prefetch={true}` (migration aid).

### Files changed (non-test, non-Turbopack)

- `packages/next/src/build/segment-config/app/app-segment-config.ts` — schema accepts new `'partial'` and `'unstable_eager'` values
- `packages/next/src/server/config-schema.ts`, `config-shared.ts`, `config.ts` — new top-level `partialPrefetching` config option (`boolean | 'unstable_eager'`)
- `packages/next/src/server/app-render/create-flight-router-state-from-loader-tree.ts` — threads partial-prefetch decision through tree construction
- `packages/next/src/server/app-render/walk-tree-with-flight-router-state.tsx`
- `packages/next/src/server/app-render/app-render.tsx`, `types.ts`, `base-server.ts`
- `packages/next/src/client/components/segment-cache/scheduler.ts`
- `packages/next/src/shared/lib/app-router-types.ts`

## Impact on vinext

This extends the surface tracked in #849 (`unstable_prefetch` segment config). Two new pieces:

1. **`unstable_prefetch = 'partial'`** — vinext's segment config validation/parsing (issue #849) should accept this value (and `'unstable_eager'`) without warning. Whether to act on it is gated on whether vinext implements Cache Components prefetching at all.
2. **Top-level `partialPrefetching` config** — vinext's next.config.js compatibility layer (see config compat matrix) should at minimum recognize this option as known. Acting on it requires the same segment-cache scheduler work tracked in #1614.

Both options are new since this is now the Cache Components prefetching control surface. Even before vinext implements the runtime behavior, the config parser/validator should not error or warn on these values.

## Related

- #849 — `unstable_prefetch` segment config (this PR extends the accepted values)
- #1614 — Client-side App Shell prefetching (the runtime that this config drives)
- #1427 — Server-side App Shell prefetch handler

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.