Commit Graph

3804 Commits

Author SHA1 Message Date
Josh Story d424aa8ec4 Stabilize unstable_instant (#94578)
This API has experimental modes for build validation but the dev
validation is going to be stable in the next release.
2026-06-09 13:50:25 -07:00
Joseph 9e4d718de4 docs: root-params highligth fixes (#94620)
Once again, reformatting broke the highlights
2026-06-09 20:10:27 +00:00
Jiwon Choi 3d920355dd Revert "Stabilize catchError and retry by removing unstable_ prefix" (#94617)
Reverts vercel/next.js#94610

Unblock
2026-06-09 19:47:48 +00:00
Jiwon Choi 6b3936a332 Stabilize catchError and retry by removing unstable_ prefix (#94610)
### What?

Promotes two experimental error-handling APIs to stable by dropping the
`unstable_` prefix:

- `unstable_catchError` → `catchError` (exported from `next/error`)
- `unstable_retry` → `retry` (the prop Next.js injects into `error.js` /
`global-error.js` boundaries and `catchError` fallbacks)

### Why?

Both were introduced as `unstable_` in `v16.2.0` and are now stable as
of `v16.3.0`. The experimental prefix should be removed from the stable
surface.

### How?

- Renamed the `next/error` export (`error.d.ts`, `error.js`,
`src/api/error.ts`, `src/api/error.react-server.ts`) and the
implementation in `client/components/catch-error.tsx`.
- Renamed the framework-injected `retry` prop across
`error-boundary.tsx`, `builtin/global-error.tsx`, the dev-overlay error
boundary, and the `ErrorInfo` type.
- Updated the RSC client-only export list in the SWC transform
(`react_server_components.rs`) so importing `catchError` in a Server
Component still produces the "only available in Client Components"
error.
- Updated the thrown error messages and their `errors.json` entries
(codes 1138/1139), the TypeScript-plugin serialization-exemption rule,
all affected tests, the rspack test manifests, and the docs.
- Docs version-history tables keep the historical `unstable_` rows and
add a `v16.3.0` row noting the rename to stable.

This is a clean rename with **no** backward-compatible `unstable_`
alias.

### Verification

- Passed: pre-commit hooks (`prettier`, `eslint --fix`, `rustfmt`) on
all 35 changed files.
- Passed: repo-wide grep confirms no remaining `unstable_catchError` /
`unstable_retry` outside the intended historical version-history rows.
- In progress locally (covered by CI): `pnpm build-all` (native SWC
still compiling on a fresh worktree), then `pnpm --filter=next types`
and the targeted e2e suites (`app-dir/catch-error`, `app-dir/errors`,
`rsc-build-errors`, typescript-plugin `client-boundary`).

<!-- NEXT_JS_LLM_PR -->
2026-06-09 21:05:02 +02:00
Aurora Scharff 5b99d26df8 instant: polish client-hook overlay wording, cards, and docs links (#94496)
### What?

Polishes the dev-overlay UX for the client-hook prerender error after
Josh's framework fix landed in
[#94494](https://github.com/vercel/next.js/pull/94494). The overlay now
names the hook in the headline and shows per-hook fix cards.

### Why?

Different hooks need different fixes. `useSearchParams` always suspends,
but `generateStaticParams` doesn't apply to it. `useParams` is the only
hook GSP resolves at build time. `usePathname` and
`useSelectedLayoutSegment(s)` need a Suspense boundary or the `[block]`
export.

### How?

- Headline now reads "Next.js encountered URL data `useX()` in a Client
Component outside of `<Suspense>`", matching the body factory wording.
- Per-hook card sets in `instant-guidance-data.ts`: `useSearchParams` →
Stream + Block; `useParams` → Stream + GSP + Block; `usePathname` /
`useSelectedLayoutSegment(s)` → Stream + Block.
- Build-time message in `ClientHookDynamicError` /
`ParamClientHookDynamicError` matches the overlay card set.
- Companion docs page:
[vercel/front#72622](https://github.com/vercel/front/pull/72622).

### Verification

Demo scenarios on the [error-messages-overhaul test
app](https://error-messages-overhaul-ibsl.labs.vercel.dev/):
[88-client-use-pathname](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/88-client-use-pathname),
[89-client-use-search-params](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/89-client-use-search-params),
[90-client-use-params](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/90-client-use-params),
[91-client-use-selected-layout-segment](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/91-client-use-selected-layout-segment),
[92-client-use-selected-layout-segments](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/92-client-use-selected-layout-segments).

<!-- NEXT_JS_LLM_PR -->

---------

Co-authored-by: Josh Story <gnoff@storyposted.com>
2026-06-09 15:20:11 +02:00
Karl Horky ca2a022c26 docs: fix 'time zone' spelling in FOUC guide (#93244)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Signed commits

- This repository requires verified commit signatures on protected
branches.
- If this pull request is blocked for unsigned commits, re-sign the
commits and force-push the branch.
- A `Signed-off-by` line in the commit message is not enough.


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

Followup to https://github.com/vercel/next.js/pull/92786 by @icyJoseph
and @feedthejim, reviewed by @aurorascharff

### What?

Switch "timezone" to "time zone"

### Why?

"time zone" (with a space) is the more common spelling of the term:

-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/ZonedDateTime#time_zones_and_offsets
- https://date-fns.org/v4.1.0/docs/Time-Zones
- https://datatracker.ietf.org/doc/rfc9557/
- https://www.iana.org/time-zones
- https://www.postgresql.org/docs/current/datatype-datetime.html
- https://unicode-org.github.io/icu/userguide/datetime/
- https://www.merriam-webster.com/dictionary/time%20zone

### How?

Manual replacement

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-06-09 10:28:27 +02:00
Josh Story adb2913661 Stabilize export const prefetch (#94571)
This API is going to ship stable but some options may individually be
marked unstable
2026-06-08 18:30:55 -07:00
Jude Gao 7dfd46481c [Docs] Remove unstable_instant agent hints; insights validate by default (#94577) 2026-06-08 17:30:51 -07:00
Josh Story a9539183b8 Rename prefetch option force-runtime to allow-runtime (#94568)
While force-runtime does opt you into runtime prefetching today (i.e. it
does force) the intended semantic is shifting to convey that the Segment
itself is designed for and makes sense (i.e. cost / performance
tradeoff) to runtime prefetch. In the future segments that may be
runtime prefetched might not be for various optimization reasons. We
therefore are renaming the option from force-runtime to allow-runtime.
In the future if we change allow-runtime to sometimes not runtime
prefetch we can always ship a new force-runtime as a codemod option that
recovers the current behavior.

This wording also better demonstrates why this is a feature of the
Segment and not say an option on the link like `<Link
prefetch="force-runtime" />`.
2026-06-08 17:02:16 -07:00
Danyal Ahmed 5c9bc5c8ec docs: fix onRequestError error type example (#94518)
### Fixes #94499


### Summary

The `Instrumentation.onRequestError` type currently exposes the error
parameter as `unknown`, but the docs described it as `Error & { digest:
string }` and the example accessed `err.message` directly.

This updates the docs/example to match the current type and narrows the
caught value before reading `message`.

### Tests:
- `git diff --check`
2026-06-08 22:35:23 +00:00
Luke Sandberg 7041635b10 enable eviction by default (#94452)
Enable memory eviction by default

If this causes trouble setting
`experimental.turbopackMemoryEviction=false` can disable this feature.
2026-06-08 15:01:52 -07:00
Joseph 9cde916966 docs: clarify use cache persistence across deploys (#93554)
Clarify caching directives non-persistence across deploys.

- [x] reinforce that in serverless deploys, the `use cache` directive
doesn't persist between requests/different instances either
2026-06-08 21:04:04 +00:00
Aurora Scharff 5e14410395 docs: add updateTag example to cacheTag page (#94508)
### What?

Adds an `updateTag` example to the `cacheTag` API reference page.

### Why?

The `cacheTag` docs only showed `revalidateTag` for cache invalidation.
For forms and user-triggered mutations (the dominant use case for
`cacheTag`), `updateTag` is the recommended API because it provides
read-your-own-writes semantics. DX agent friction logs showed agents
defaulting to `revalidateTag` and hitting the deprecated single-arg
error before discovering `updateTag` via web search.

### How?

Added a second example block after the existing `revalidateTag` one,
showing `updateTag('my-data')` in a Server Function.

Co-authored-by: Joseph Chamochumbi <joseph.chamochumbi@vercel.com>
2026-06-08 14:09:37 +00:00
SJvaca30 bd9f0eb41b docs: clarify next-env.d.ts regeneration (#94232)
## What?

Closes #94153.

Clarifies that `next-env.d.ts` is managed by Next.js and that its
contents may change over time, including between commands such as `next
dev` and `next typegen`.

## Why?

Projects that still track `next-env.d.ts` can see command-order diffs
when the generated route type imports switch between `.next/dev/types`
and `.next/types`. The docs already recommend excluding the file from
version control; this makes the generated-file contract and manual-edit
guidance explicit.

## Testing

- `npx --yes prettier@3.6.2 --check
docs/01-app/03-api-reference/05-config/02-typescript.mdx`
- `git diff --check`
2026-06-08 14:47:33 +02:00
Luke Sandberg f32234cc1a Turbopack: Add an experimental option for eviction (#94439)
`experimental.turbopackMemoryEviction = "full" | false`

controls the new feature, currently it is disabled.
2026-06-07 16:38:35 +00:00
Razin Shafayet 2aefd05123 docs: fix typos in contribution guide (#94375)
Fixed `search from` → `search for` and `at the of the page` → `at the
top of the page` (confirmed by checking API ref pages — overview tables
go at the top after a short intro and example).
2026-06-05 00:03:33 +02:00
Aurora Scharff e81c12b5f2 docs: document Cache Components behavior for navigation hooks (#94387)
### What?

Adds a `## Behavior` → `### Cache Components` section to the API
reference pages for `usePathname`, `useSelectedLayoutSegment`, and
`useSelectedLayoutSegments`.

### Why?

When `cacheComponents` is enabled, these hooks suspend during
prerendering on routes that have dynamic params not covered by
`generateStaticParams`. This was previously only hinted at with a
one-line note on `usePathname` and undocumented on the layout segment
hooks, even though they share the same behavior.

### How?

- `usePathname`: replaced the terse one-line note with a `## Behavior` →
`### Cache Components` section explaining when it resolves on the server
vs. suspends. Also added a link to the [Preventing flash before
hydration](/docs/app/guides/preventing-flash-before-hydration) guide in
the existing rewrite-mismatch example, and cleaned up a stray em dash.
- `useSelectedLayoutSegment`: added the same `### Cache Components`
section.
- `useSelectedLayoutSegments`: added the same `### Cache Components`
section.

The rewrite/Proxy hydration-mismatch gotcha is intentionally not
duplicated to the layout segment pages — those hooks derive their value
from the routing tree, not the URL pathname, so rewrites don't produce
the same mismatch.

Documents existing behavior only — no API surface changes.
2026-06-03 14:19:30 +02:00
Joseph 2442dc0b70 docs: cached functions from the client (#94301)
It is possible to call cached functions from the client, under a couple
of conditions.

Rather than introducing this as a pattern now, let's start with a
callout.

Similarly (extending) Server Functions, the client only sees a
reference, no implementation details leak.
2026-06-02 17:32:42 +02:00
Joseph d3cd368181 docs: update draftMode guide (#94155)
Reframes the Draft Mode guide so the headline is "every Next.js cache
layer is bypassed for the request," not "switch to dynamic rendering."
The previous guide led with an `isEnabled` fork in `getData()`, which
implied users have to branch their fetch code to make caching step
aside. They don't.

Changes:

- Intro lists the bypassed layers (`fetch` cache, `'use cache'`,
`unstable_cache`, ISR response cache).
- Step 3 fetches from a single endpoint with no `isEnabled` branch.
- New Step 4 shows a preview banner + disable handler, which is where
`isEnabled` is actually useful.
- The "Cache Components" example uses `isEnabled` for a UI indicator
instead of branching the fetch URL.
- Two-URL fork demoted to a final section for CMSs that genuinely need
it.
2026-06-02 17:29:47 +02:00
Joseph 044e25ac20 doc: clarify rewrites execution order (#93765)
Rework the execution order of rewrites.

- before and after Files execution is now clearer - when a source
matches and how the destination resolves
- explicit `dynamic routes` step (similar to Proxy's,
https://nextjs.org/docs/app/api-reference/file-conventions/proxy#execution-order)

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2026-06-02 17:28:14 +02:00
Sam Selikoff aa59b0464c Remove the instantNavigationDevToolsToggle flag (#94322)
Remove the `instantNavigationDevToolsToggle` experimental flag and show
the Navigation Inspector whenever `cacheComponents` is enabled. Also
updates docs and test fixtures that referenced the old flag.
2026-06-02 10:43:22 -04:00
Joseph bc384860d5 docs: accuracy and pappercuts (#94299)
Exhaustive pass over the guides and getting started using audit-docs
skill.
2026-06-01 22:28:44 +02:00
Joseph 13847b2e9f docs: bodySizeLimit measures raw HTTP body (#94137)
Started from https://github.com/vercel/next.js/discussions/93989 

Noticed we even have a test helper to account for overhead:


https://github.com/vercel/next.js/blob/fa4c0def823447e75366153690abeda79c7c4ec2/test/e2e/app-dir/actions/account-for-overhead.js#L1-L11

Let's document that the flag controls the raw http body size, overhead +
data
2026-06-01 13:42:09 +02:00
Tim Neutkens 16e862ae62 docs: correct custom server optimization guidance (#94229)
## Summary

- remove the inaccurate claim that a custom server disables Automatic
Static Optimization
- retain the guidance to use a custom server only when the integrated
router cannot meet an app's requirements

## Verification

- `pnpm prettier --with-node-modules --ignore-path .prettierignore
--check docs/01-app/02-guides/custom-server.mdx`
- commit hook: `prettier --write` and `eslint --fix` for the changed MDX
file
2026-05-29 15:49:42 +02:00
Kristiyan Velkov 57ddbf81b0 [feat] updated the documentation for deployment to point to new next.js Docker official guide. (#94185)
## What?

Updates the Docker section in the deploying guide.

- Rewrites the Docker intro sentence to be more concise and adds a link
to Docker's official [React.js
guide](https://docs.docker.com/guides/reactjs) alongside the existing
[Next.js guide](https://docs.docker.com/guides/nextjs).

## Why?
Add reference to new Next.js Docker guide in the deploying docs.

## How?

Documentation-only change. No code changes.

CC: @icyJoseph
2026-05-29 15:03:17 +02:00
Stanislav Kozachenko b14d9a4213 docs: fix code examples in getting-started guides (#93273)
### What?

Fix three broken code examples in the Getting Started section.

### Why?

Per the contribution guide, code blocks should contain a minimum working
example that can be copied and pasted. These examples have bugs that
would cause runtime errors or incorrect behavior:

1. `02-project-structure.mdx`: Extra comma in App Icons table —
`apple-icon` row has `.jpg` `.jpeg`, `.png` while all other rows use
space-separated extensions without commas.
2. `03-layouts-and-pages.mdx`: `Post` component has an unused `post`
prop — the component fetches and renders all posts internally via
`getPosts()`, so the prop is never referenced. Removed the unused prop,
renamed to `Posts` to match its actual behavior, and added the missing
`import { getPosts } from '@/lib/posts'`.
3. `04-linking-and-navigating.mdx`: JSX `Layout` function is missing `{
children }` in its parameter list, causing `ReferenceError: children is
not defined` at runtime. The TSX version is correct.

### How?

- Remove stray comma from App Icons table
- Remove unused `post` prop from `Post` component, rename to `Posts`,
add missing import
- Add `{ children }` destructuring to JSX `Layout` function signature

Closes #93272

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-05-28 13:49:58 +02:00
Joseph daf10c3712 docs: move isr cacheHandler callout to next steps (#94167)
Move the ISR cacheHandler callout to next steps...
2026-05-27 21:43:11 +02:00
Igor Babko 48d3ab5c0e Remove extra word (#94160) 2026-05-27 18:25:48 +00:00
Joseph ae76532c46 docs: transpilePackages usage (#93602)
I've seen people asking about `transpilePackages` before, and now we
got: https://github.com/vercel/next.js/discussions/93542

This PR attempt to make its usage clearer.
2026-05-27 19:22:17 +02:00
Joseph fa4c0def82 docs: ISR w/ Cache Components - experimental.partialFallbacks (#93299)
Continuation of: https://github.com/vercel/next.js/pull/92619

Completing the ISR with Cache Components story.

- [x] mention to cacheHandler and cacheHandlers - these work fine
together (aka with cacheComponents activated)
- [x] prefetch behavior - background revalidation
- [x] link to demo app
- [x] update version history in partialFallbacks config
- [x] align with partialFallbacks config flag removal

Closes: https://github.com/vercel/next.js/issues/91951
2026-05-27 00:41:22 +02:00
Joseph 5795d6594a docs: add next/root-params API reference (#93764)
Continuation of: https://github.com/vercel/next.js/pull/82244

Closes:
https://linear.app/vercel/issue/DOC-4924/nextroot-params-documentation

## TODO

- [x] adjust code snippets
- [x] wait for a couple more features to land (type safety support)
- [x] Route Handlers
- [x] Supported inside generateStaticParams for nested segments
- [x] x-ref for discoverability
- [x] enabled/available without a flag - the experimental flag has been
removed
2026-05-27 00:41:01 +02:00
Joseph dc3a7ebf6e docs: rework dynamic segments intro section (#94126)
We don't refer to these as `path params` anymore, rather called them
`dynamic segments`, which causes a drop-off when people search for
"nextjs path params".

While looking at this, I also noticed that we don't really mention what
a segment, people don't know this necessarily.

We'll have to come back to this point later on because, params are just
placeholders, the dynamic qualifier is too broad, dynamic at build and
runtime is what we mean today, but arguably params known via
generateStaticParams, are no longer dynamic params, they are known set
of params.
2026-05-26 18:15:53 +02:00
Niklas Mischkulnig 797d0060df docs: instrumentationClientInject (#93913)
Add docs for https://github.com/vercel/next.js/pull/93785
2026-05-20 11:48:50 +02:00
Luke Sandberg f49ed2270f Add MCP compile_route tool (#93337)
### What?

Adds a `compile_route` MCP tool that triggers on-demand compilation of a
specific route (app or pages) without issuing an HTTP request, and
returns any compilation issues.

### Why?

Coding agents and benchmarking workflows need a way to warm the module
graph or measure compile time for a route without standing up a live
backend to satisfy the request. The existing path — hitting the URL —
requires the route's runtime dependencies to be available and couples
compile timing to request handling.

### How?

- New tool `mcp/compile_route` registered in
`get-or-create-mcp-server.ts`, backed by a `compileRoute({ page,
clientOnly })` callback plumbed from the Turbopack hot reloader
- Reuses the dev server's existing on-demand entry path (`ensurePage` /
`handleRouteType`), so the call path matches a first navigation.
- Adds a `subscribeToChanges` opt-out on `ensurePage` and threads it
through `handleRouteType` / `handlePagesErrorRoute`. One-shot MCP
compilations skip HMR subscription wiring — without this, each call
would leak a subscription that fires on every subsequent file change for
the life of the dev server.
- Telemetry: registers `mcp/compile_route` in the `McpToolName` union.
- e2e test in
`test/development/mcp-server/mcp-server-compile-route.test.ts`.

<!-- NEXT_JS_LLM_PR -->
2026-05-19 17:46:19 -04:00
Niklas Mischkulnig f46db1c4a6 Pass projectDir to adapter modifyConfig (#93916)
Adapters implementing `modifyConfig` may need to know the absolute
project directory to perform path resolution or apply directory-specific
configuration logic. Without this value, adapters had no reliable way to
determine where the application lives on disk.

onBuildComplete already received the directory as a parameter.
2026-05-18 13:35:58 +00:00
Ayodele Samuel Adebayo 22fc63da72 docs: fix typos and links (#92541)
This PR cleans up small documentation and error-page issues: correct
TypeScript spelling where it was written as “Typescript”, use the proper
GitHub label in links, fix the MDN URL for `Map.prototype.values` in the
middleware upgrade guide.

No runtime or API behavior changes.
2026-05-13 10:25:23 +02:00
Jude Gao e519ede969 docs: less aggressive AI agent hint for an experimental API (#93811)
The "AI agent hint" comment on the docs landing page (`docs/index.mdx`)
tells every agent reading the docs on every task to export
`unstable_instant` to fix slow client-side navigations.

That's too aggressive for an experimental API — `unstable_instant` is
`version: draft` and still reshaping (`unstable_prefetch` just split off
in #92754). The instant-navigation guide already covers the API in
measured language; agents working on slow-navigation tasks will find it
there.

<!-- NEXT_JS_LLM_PR -->
2026-05-13 04:06:34 -04:00
Joseph 9f3d868062 docs: devIndicators with usage example (#93784)
The devIndicator page doesn't really show that this is used in
next.config.js - in isolation an agent might not infer the right usage.
2026-05-12 11:02:46 +02:00
Andrew Clark 56d95137fd bfcacheId: Opt out of state preservation (#93633)
When `cacheComponents` is enabled, the App Router preserves state across
navigations by rendering inactive routes inside React `<Activity>`
boundaries.

As a default behavior, this is a huge convenience because it lets you
navigate between routes without resetting or losing ephemeral UI state
(scroll position, expand/collapse, in-progress form edits). Previously
the only way to do this was to explicitly track each state with an
external state manager, or hoist it to a parent component.

It's still the often the case that you should be explicitly tracking all
important UI state, anyway, so that it survives a hard refresh of the
app, or the browser window being accidentally closed. For example, forms
draft states should be persisted to a server-side database or local
storage engine. If you're already doing that, then it doesn't matter so
much whether client state is preserved via `<Activity>` boundaries or
not.

For the long tail of ephemeral state that is not tracked, Next.js's
philosophy is that it's a better UX default to preserve as much
emphemeral state as possible. It's easier to model the cases where you
_do_ want state to be reset on navigation as exceptions, compared to the
other way around.

However, this is a significant change compared to the pre-Cache
Components previous behavior of Next.js, and compared to other web
frameworks, and indeed the browser's own native bfcache (which
implements state restoration for history traversal navigations only, not
push/replace).

There's are also lots of existing codebases that may rely on the current
behavior, and may break subtly under these new semantics. Even if this
new default unlocks better UX patterns, we don't want to force everyone
to migrate all their code all at once.

So, this PR introduces a drop-in mechanism for opting out of state
preservation when navigating to a previously visited route.

The API is exposed as `useRouter().bfcacheId`. It's intended to be
passed to a React `key`:

  <form key={useRouter().bfcacheId}>

The id is contextual: read from a layout, you get the layout's id; read
from a page, you get the page's id. It's stable across back/forward
navigations, `router.refresh()`, server actions that call `refresh()`,
and search-param- or hash-only navigations — i.e., any time the
surrounding segment is preserved. It changes when the segment is freshly
created by a push or replace into a different route.

An important detail is that the previous id is restored during a back/
foward navigation. So state preservation will still work if you navigate
via the browser's back button.

Why add this to `useRouter()` instead of giving it its own hook? The
intent is communicate that `bfcacheId` is not considered an idiomatic
pattern — the recommended fix for "I want this state to reset on
navigation" is almost always something else: an explicit reset in a
submit handler, or a key derived from the underlying data (e.g., a draft
id from the server). `useRouter` is the hook where we expose low-level
APIs that are supported but are only recommended for advanced or
exceptional cases. (For example, instead of `router.push()`, you should
almost always use a `<Link>` component instead.)
2026-05-11 20:01:42 -04:00
Joseph 63cd4233b4 docs: clarify cacheTag limit - it is per call (#93768)
x-ref: https://vercel.slack.com/archives/C03S8ED1DKM/p1778515581719889
2026-05-11 23:19:03 +00:00
Josh Story 766b7cbff4 Stabilize unstable_io (#93621)
Removes the unstable prefix from `unstable_io`. Since this was only
shipped in canaries with the unstable prefix we are going to just remove
it without retaining the unstable prefix simultaneously.
2026-05-07 16:39:37 -07:00
Joseph 0b8a0fb429 docs: escape literal triple-backticks in contribution guide (#93584)
Updates:
https://nextjs.org/docs/community/contribution-guide#language-and-filename

to:


<img width="1335" height="690" alt="Screenshot 2026-05-07 at 14 26 35"
src="https://github.com/user-attachments/assets/588799a3-1a0e-4696-9600-627df270f48e"
/>
2026-05-07 14:46:44 +02:00
Josh Story d86e197728 Support configuring a default instant validation level (#93301)
Adds `experimental.instantInsights.validationLevel` so an app can opt
into instant validation for all routes by default.

There are two public levels
* `manual-warning`: currently the default. this mode won't enable
instant validation except where you add `export const unstable_instant =
true` into your Layouts, Pages, and Default files
* `warning`: This mode will enable instant validation for all Page and
Default files. You can override this with `export const unstable_instant
= false` in Layouts, Pages, and Default files to tune what navigations
are validated.

In addition this change disables build time validation.

There is a now undocumented way to get back to running build validation
with
* `experimental-error`
* `experimental-manual-error`

The build validation isn't ready for users because we need to overhaul
the setup where you provide cookies and other sample values so we can
run validation without a live session like we do in dev.

To further support this the two remaining object properties that are
also not ready for active use, `samples` and `from` are being updated to
`unstable_samples` and `unstable_from` respectively.

We will continue to iterate on build time validation but may remove
these APIs or alter their semantics as we figure out a more ergonomic
way to support this setup.

In anticipation of multiple levels the object form of `instant` can be
provided a level value `warning` or `experimental-error`. this latter
option is similarly undocumented so documented behavior will only cover
`warning` which is generally a synonym of true unless you are activating
error by default
2026-05-06 10:37:50 -07:00
Joseph 506e5ac110 docs: broken link from usePathname compat call out (#93528)
The compatibility section in `usePathname` used a broken link - in the
sense that it links to the wrong page.
2026-05-06 10:53:03 +02:00
Joseph 8f68464f9a docs: remove unreachable forms and mutations (#93509)
Remove
/02-pages/03-building-your-application/03-data-fetching/03-forms-and-mutations.mdx
- which is not reachable from the site, because it has been replaced by
the https://nextjs.org/docs/pages/guides/forms guide.
2026-05-06 09:34:01 +02:00
Josh Story b40a8d4f9a Update unstable_prefetch and unstable_instant docs to reflect current API shape (#93514)
Updates docs to reflect the current shape of these APIs. these will
change further when we land default avlidation and switch to levels.
2026-05-05 14:53:26 -07:00
Armando A. Calderón d38b4c2256 docs: clarify proxy runtime history (#93467)
### What?

Clarifies the Proxy docs so the “Why Proxy” section no longer appears to
contradict the Runtime section.

### Why?

The Runtime section states that Proxy defaults to the Node.js runtime,
but the “Why Proxy” section still said Middleware defaults to the Edge
Runtime. Since Middleware was renamed to Proxy in v16, that wording
could make readers think the current default runtime is Edge.

### How?

Updates the “Why Proxy” paragraph to frame Edge Runtime wording as
historical context rather than current default behavior.

Also updates the v16.0.0 version history entry to mention that Proxy
defaults to the Node.js runtime.

Closes #93463

---------

Co-authored-by: Joseph <sephxd1234@gmail.com>
2026-05-05 14:47:03 +00:00
Rishi 5452439f3d fix(next/image): Improve error message for private IP (SSRF) rejections (#91686)
Co-authored-by: Steven <steven@ceriously.com>
2026-05-04 19:15:32 +02:00
Tim Neutkens 65340b2772 feat(metadata): support non-standard directives in robots.ts via other (#93206)
### What?

Adds an `other` field to each rule in `MetadataRoute.Robots` so
`app/robots.ts` can emit non-standard per-user-agent directives (e.g.
Seznam `Request-Rate`, Yandex `Clean-param`) alongside the standard
`allow`/`disallow`/`crawlDelay` fields.

```ts
// app/robots.ts
export default function robots(): MetadataRoute.Robots {
  return {
    rules: [
      { userAgent: '*', allow: '/' },
      {
        userAgent: 'SeznamBot',
        allow: '/',
        other: { 'Request-Rate': '10/1m' },
      },
    ],
  }
}
```

emits:

```
User-Agent: *
Allow: /

User-Agent: SeznamBot
Allow: /
Request-Rate: 10/1m
```

### Why?

The current `resolveRobots` serializer only writes the four standard
rule fields and silently drops everything else, so users who need
non-standard directives (common for Seznam, Yandex, and other crawlers)
have to delete `robots.ts` entirely and hand-maintain a static
`robots.txt`, losing the type-safe, code-driven workflow.

### How?

- **Type**
(`packages/next/src/lib/metadata/types/metadata-interface.ts`): factored
a shared `RobotsRuleBase` containing the existing optional fields plus
`other?: Record<string, string | number | Array<string | number>>`.
`RobotsFile.rules` still enforces `userAgent` as required on the array
form.
- **Serializer**
(`packages/next/src/build/webpack/loaders/metadata/resolve-route-data.ts`):
after `Crawl-delay` and before the trailing blank line, walks
`rule.other` and emits `Key: value` lines preserving casing. Array
values expand into repeated lines; `null`/`undefined` entries are
skipped. Keeps non-standard directives scoped to their `User-Agent`
block.
- **Tests**: added two `resolveRobots` cases covering the `Request-Rate`
reproduction and an array-valued `Clean-param`, plus null/undefined
handling. Existing snapshots are unchanged, proving the change is
additive.
- **Docs**: new "Non-standard directives" section in
`docs/01-app/03-api-reference/03-file-conventions/01-metadata/robots.mdx`
with TS/JS examples and updated `Robots` type reference.

Fixes #89521

<!-- NEXT_JS_LLM_PR -->
2026-05-01 12:11:53 +02:00
Joseph acb41ed606 docs: clarify rendering flow in Server/Client interleaving example (#93381)
follow up to: https://github.com/vercel/next.js/pull/93374
2026-04-30 12:03:27 +00:00