Commit Graph

3804 Commits

Author SHA1 Message Date
Jimmy Lai eb44c314dc docs: platform portability and infrastructure documentation (#91237)
## Summary

Adds comprehensive documentation addressing platform partner feedback
about Next.js portability, infrastructure requirements, and CDN caching.
All technical claims verified against the codebase.

**New pages (5):**
- **Rendering Philosophy** — explains Next.js's component-level
static/dynamic spectrum, framework comparisons, functional vs.
performance fidelity definitions, CDN compatibility
- **Deploying to Platforms** — feature support matrix
(streaming/cache/edge requirements per feature), CDN infrastructure
table, minimum requirements, adapter guidance
- **How Revalidation Works** — tag system architecture (explicit + soft
tags with `_N_T_` prefix), HTML/RSC consistency requirements,
multi-instance coordination, graceful degradation
- **CDN Caching** — cache variability (`Vary` headers, `_rsc` param),
graceful degradation when headers are dropped, static prefetch caching
(PPR-scoped), pathname-based cache keying direction
- **PPR Platform Guide** — implementation tiers (origin-only through
edge), resume protocol (`next-resume` header, POST + body), artifact
storage, implementation checklist

**Expanded pages (4):**
- **Self-Hosting** — streaming infrastructure requirements,
multi-instance cache coordination, CDN guide links, graceful shutdown
details
- **ISR** — multi-instance caveats, tag propagation, background
regeneration billing, `x-nextjs-cache` monitoring
- **Cache Handlers** — distributed tag coordination (Redis example),
soft tags explanation, stream handling, error handling patterns
- **Adapter API** — runtime integration context, PPR chain headers
(`next-resume`), multi-instance cache entry propagation, fixed stale
`x-nextjs-resume` comment

## Key corrections from code verification
- Resume header is `next-resume`, not `x-nextjs-resume` (fixed in
existing adapterPath docs too)
- Resume requires POST with postponed state in body, not just a header
- `x-nextjs-cache` has 4 values including `REVALIDATED`, only emitted
outside minimal mode
- Soft tags use `_N_T_` prefix with layout paths (`_N_T_/blog/layout`),
not bare paths
- `stale-while-revalidate` in Cache-Control is conditional on `expire`
config
- Static prefetch caching without state tree only works for PPR-enabled
routes
- Fastly product renamed from `Compute@Edge` to `Compute`

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2026-03-23 12:09:42 -07:00
Jiwon Choi ee6a0d7715 docs: add catchError benefits over userspace error boundaries (#91745)
## Summary

- Add bullet list explaining three key benefits of `unstable_catchError`
over a plain React error boundary: built-in error recovery via
`retry()`, framework-aware handling of `redirect()`/`notFound()`, and
automatic error state clearing on client navigation.

[slack
thread](https://vercel.slack.com/archives/C02CDC2ALJH/p1774047269162799)
2026-03-23 14:06:39 +01:00
Jiwon Choi 9fdd5bcd77 docs: use ErrorInfo type consistently in catchError docs (#91744)
## Summary

- Replace inline types with `ErrorInfo` in all TSX examples in
`catchError.mdx`
- Merge separate `import type { ErrorInfo }` into single import
statement
- Remove broken `highlight` attributes from "Recovering from errors"
code blocks
- Stop aliasing `unstable_retry` to `retry` — use `unstable_retry`
directly in all examples
- Use "children" instead of "contents" in error boundary descriptions
(`catchError.mdx`, `error.mdx`)
2026-03-22 23:02:24 +01:00
Joseph 04cc2f2ed2 docs: post release amends (#91715)
Fixes based on feedback post release

Fixes: https://github.com/vercel/next.js/pull/91715
2026-03-20 15:47:19 +01:00
Abhishek Mardiya 883d93c893 docs: fix broken Activity Patterns demo link in preserving UI state guide (#91698)
## What?

Fixes a broken link in the Preserving UI State guide:
https://nextjs.org/docs/app/guides/preserving-ui-state#examples

The "Activity Patterns demo" link currently points to a non-working URL.

## Why?

The demo link returns a 404 / invalid page, which makes the example
section confusing for readers.

## Changes

- Updated the Activity Patterns demo link to the correct URL.

## Notes

No functional changes, docs only.

@icyJoseph @delbaoliveira
2026-03-20 10:00:54 +01:00
Tim Neutkens 89871864ed Rename /_next/webpack-hmr to /_next/hmr (#91415)
## What

Rename the HMR WebSocket path from `/_next/webpack-hmr` to `/_next/hmr`.

## Why

The `webpack-hmr` name is a leftover from when webpack was the only
bundler. Now that Turbopack is the default bundler for both `next dev`
and `next build`, the path name is misleading. The generic `/_next/hmr`
better reflects that this endpoint is bundler-agnostic.

## Changes

- **Client source** (`page-bootstrap.ts`, `web-socket.ts`): updated the
WebSocket connection path
- **Server** (`router-server.ts`): updated the HMR request detection
path
- **Turbopack** (`turbopack-dev-server/src/lib.rs`): updated the
fallback WebSocket path check
- **Tests**: updated all test files referencing the old path
- **Docs** (`version-12.mdx`): added a note that the path was renamed to
`/_next/hmr` in Next.js 16, while keeping the original v12 examples
intact
2026-03-19 16:39:45 +01:00
Joseph bcd9c19a61 docs: Clarify ignoreBuildErrors behavior (#91367)
Just a complementary note to the TS config reference.
2026-03-18 16:54:42 +01:00
Richard Zhang b61823d7b9 SRI turbopack documentation (#90477)
<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
Updates the Subresource Integrity (SRI) documentation to reflect that
the feature is now supported on both Webpack and Turbopack bundlers.

Previously, the documentation stated that SRI was "only available with
webpack bundler". This has been updated to remove that restriction
following the implementation in PR #90152.

### Changes
- Removed webpack-only limitation from SRI documentation in Content
Security Policy guide
- Removed `experimental.sri.algorithm` from the list of unplanned
Turbopack features

Fixes the documentation to align with the current implementation.
<!-- CURSOR_AGENT_PR_BODY_END -->

[Slack
Thread](https://vercel.slack.com/archives/D0AGHCN7K2T/p1771984911390169?thread_ts=1771984911.390169&cid=D0AGHCN7K2T)

<div><a
href="https://cursor.com/agents/bc-0b4d6ed8-9e06-5c78-9a4d-b352a7c2e97d"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-0b4d6ed8-9e06-5c78-9a4d-b352a7c2e97d"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Richard Zhang <richardjzhang@users.noreply.github.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-03-18 09:59:35 +01:00
Zack Tanner b2b802c043 block disallowed dev origins by default (#91507)
This removes the warn-only default behavior and enforces the dev-origin guard by default. Cross-origin requests to internal dev resources now block unless they match the built-in local allowlist or an explicit `allowedDevOrigins` entry. The tests are expanded to cover default blocking, configured-but-not-allowlisted hosts, missing Referer in the no-cors path, and same-site requests without an Origin, and the docs are updated to match the new behavior.
2026-03-17 16:02:33 -07:00
Tim Neutkens 97f420911d Move adapterPath from experimental to stable top-level config (#91535)
## Move `adapterPath` from experimental to stable

Graduates `adapterPath` from `experimental.adapterPath` to a top-level
`NextConfig` option, following the same pattern used for
`cacheHandlers`, `cacheComponents`, `typedRoutes`, and other options
that moved out of experimental.

### Changes

- **Type definition** (`config-shared.ts`): Added `adapterPath` to
`NextConfig` interface, marked `ExperimentalConfig.adapterPath` as
`@deprecated`, moved default value to top-level in `defaultConfig`,
updated `NextConfigRuntime` and `getNextConfigRuntime`
- **Zod schema** (`config-schema.ts`): Added `adapterPath` to top-level
`configSchema`
- **Backward compat** (`config.ts`): Added
`warnOptionHasBeenMovedOutOfExperimental` call so existing
`experimental.adapterPath` configs still work with a deprecation
warning, updated `applyModifyConfig` to read from `config.adapterPath`
- **Runtime references**: Updated `build/index.ts`, `app-page.ts`,
`app-route.ts`, `pages-handler.ts` to use `config.adapterPath` /
`nextConfig.adapterPath`
- **Tests**: Updated 4 test fixture `next.config` files
- **Docs**: Updated app router doc (removed `version: experimental`
frontmatter, top-level config example), pages router doc title, and v16
upgrade guide
2026-03-17 23:28:08 +01:00
Jiwon Choi 66bbcb5819 docs: unstable_catchError() (#89847)
Docs for https://github.com/vercel/next.js/pull/89688
2026-03-17 15:09:39 +01:00
Jude Gao 0e3b35ecda Add eval and docs for unstable_instant (#91334) 2026-03-13 23:02:04 -04:00
Kahfi Elhady 914df17a13 docs: remove incorrect _document.tsx font example (#91346)
saw the issue about the _document.tsx example not working. next/font
cant be used in _document.tsx, it throws an error. removed that section
from the docs since _app.tsx already has the correct example.

fixes #88832

Co-authored-by: Kahfi Elhady <kahfie@gmail.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-03-14 01:39:40 +01:00
JJ Kasper 07189c5224 Expose edge runtime fields in build-complete (#91239)
### What?

- Add canonical edge entrypoint metadata to edge function definitions in
the middleware manifest.
- Surface that canonical entrypoint through `build-complete` as
`edgeRuntime` metadata in adapter outputs.
- Update middleware and adapter tests to assert the new metadata instead
of relying on bundler-specific emitted file names.

### Why?

Adapter consumers need a stable way to load and invoke edge outputs
without depending on `next-server`'s sandbox handling or guessing which
emitted file is the executable entrypoint. The existing checks were also
brittle across webpack and Turbopack because the emitted file lists can
differ.

### How?

- Add an optional `entrypoint` field to `EdgeFunctionDefinition` and
populate it in both the webpack middleware manifest generator and the
Turbopack manifest emitters for app, pages, and middleware edge
functions.
- In `packages/next/src/build/adapter/build-complete.ts`, use that
canonical entrypoint for `filePath` and expose `edgeRuntime.modulePath`,
`edgeRuntime.entryKey`, and `edgeRuntime.handlerExport` for edge
outputs.
- Adjust the middleware manifest tests to validate cross-bundler
invariants and add adapter-config coverage for the new `edgeRuntime`
fields.
2026-03-13 18:22:47 +00:00
JJ Kasper d5e886399c Expose resolved invocation targets in next-routing (#91242)
### What?

This PR extends `@next/routing` so `resolveRoutes()` returns the
concrete route resolution data callers need after rewrites and dynamic
matches:

- rename `matchedPathname` to `resolvedPathname`
- add `resolvedQuery`
- add `invocationTarget` for the concrete pathname/query that should be
invoked
- export the new query/invocation target types from the package
entrypoint

It also removes the leftover `query` alias so the result shape
consistently uses `resolvedQuery`.

### Why?

`matchedPathname` only described part of the result, and it was
ambiguous for dynamic routes because the resolved route template and the
concrete invocation target are not always the same thing.

For example, a dynamic route can resolve to `/blog/[slug]` while the
actual invocation target is `/blog/post-1`, and rewrites can merge query
params that callers need to preserve. Exposing these values directly
makes the package easier to consume from adapters without each caller
reconstructing them manually.

### How?

- thread resolved query construction through the route resolution paths
- build `invocationTarget` alongside `resolvedPathname` wherever
rewrites, static matches, and dynamic matches resolve successfully
- preserve merged rewrite query params in `resolvedQuery`
- update the public types, README example, and existing tests to use
`resolvedPathname`
- add coverage for resolved query + invocation target behavior on
rewrite and dynamic route matches

Verified with:
- `pnpm --filter @next/routing test -- --runInBand`
- `pnpm --filter @next/routing build`
2026-03-13 09:39:29 -07:00
Delba de Oliveira 2accf8bc41 Docs: Split route segment config options into their own files (#90991)
Closes:
https://linear.app/vercel/issue/DOC-6221/nextjs-split-route-segments-files-in-preparation-for-instant
2026-03-13 13:00:00 +00:00
JJ Kasper 90861b0f34 feat(server): expose requestMeta router helpers and merge fallback context (#91235)
### What?

This PR exposes adapter-facing router helpers on `requestMeta` for
Node.js entrypoints and updates route modules to merge those
request-scoped values with the existing router server context fallback.
It also documents the new adapter contract in the `adapterPath` docs.

### Why?

When adapters invoke the Node.js handler directly, some router helpers
are needed by route handlers but currently only exist behind internal
globals. Passing them through `requestMeta` makes those helpers
available through the public handler options and still preserves the
existing fallback context for the current `relativeProjectDir`.

### How?

- add typed `requestMeta` fields for `hostname`, `revalidate`, and
`render404`
- add a `RouteModule` helper that reads the existing router server
context and overlays request-scoped values from `requestMeta`
- switch the route-module callsites that read router server context to
use the merged result
- document how adapters can pass these helpers when calling
`handler(req, res, { requestMeta })`
2026-03-12 21:33:50 +00:00
JJ Kasper bf56c71261 Preserve RSC metadata in Proxy request with skipProxyUrlNormalize (#91213)
## Summary
- preserve Flight/RSC headers on the Proxy request instance when URL
normalization is skipped (`skipProxyUrlNormalize`)
- preserve the `_rsc` query on the request URL in that same mode so
custom proxy logic can access it
- document this behavior in the Proxy API docs, including guidance for
`NextResponse.rewrite()` vs custom `fetch` rewrites
- add an e2e regression in `skip-trailing-slash-redirect` to verify
middleware receives `_rsc` and all RSC headers on the request instance

## Testing
- `NEXT_SKIP_ISOLATE=1 NEXT_TEST_MODE=dev pnpm testheadless
test/e2e/skip-trailing-slash-redirect/index.test.ts`
2026-03-11 23:06:09 +00:00
Tobias Koppers 187f35f287 Add experimental.lightningCssFeatures config option (#90901)
### What?

Adds a new `experimental.lightningCssFeatures` config option that lets
users control which CSS features lightningcss should always transpile
(`include`) or never transpile (`exclude`), regardless of browserslist
targets.

```js
// next.config.js
module.exports = {
  experimental: {
    useLightningcss: true,
    lightningCssFeatures: {
      include: ['light-dark', 'oklab-colors'],
      exclude: ['nesting'],
    },
  },
}
```

### Why?

Currently, lightningcss feature transpilation is determined solely by
browserslist targets. There's no way to force transpilation of a
specific feature (e.g., `light-dark()`) when targeting modern browsers
that already support it, or to skip transpilation of a feature that the
user wants to preserve as-is.

This is useful for:
- Forcing polyfill-style transpilation for features with incomplete
browser support
- Testing transpiled output for specific features
- Opting out of specific transforms that may interfere with CSS tooling
downstream

### How?

**TypeScript config & validation:**
- `config-shared.ts`: `LIGHTNINGCSS_FEATURE_NAMES` const array (single
source of truth) with `LightningCssFeature` type derived from it, and
`LightningCssFeatures` interface
- `config-schema.ts`: Zod validation using
`z.enum(LIGHTNINGCSS_FEATURE_NAMES)` for both include/exclude arrays

**Feature name → bitmask mapping (Rust, shared via NAPI):**
- `crates/next-core/src/next_config.rs`:
`lightningcss_feature_names_to_mask()` maps feature name strings to
`lightningcss::targets::Features` bitflag constants and returns a
`Result<u32>` bitmask. Unknown feature names produce an error via
`bail!`.
- Exposed to JS via NAPI as `lightningcssFeatureNamesToMaskNapi`,
callable through `bindings.css.lightning.featureNamesToMask(names)`
- Single source of truth for feature name resolution — both webpack and
Turbopack paths use this Rust function

**Webpack path:**
- `global.ts` / `modules.ts` pass config through to loader options
- `loader.ts` calls `featureNamesToMask()` via the native bindings to
compute include/exclude masks, then passes them to the SWC `transform()`
call
- The `lightningCssFeatures` without `useLightningcss` warning only
shows when using webpack (Turbopack always uses lightningcss)

**Turbopack path (Rust):**
- `next_config.rs`: `LightningCssFeatures` struct for deserialization,
accessor methods converting names → u32 bitmask via
`lightningcss_feature_names_to_mask()`
- Config flows through `CssOptionsContext` → `ModuleType::Css` →
`CssModuleAsset` (using `LightningCssFeatureFlags { include, exclude }`
struct) → `process.rs` where bitmasks are merged into
`lightningcss::targets::Targets { include, exclude }`
- Uses `u32` bitmask representation throughout to avoid adding
lightningcss dependency to non-CSS crates

**Defaults preserved:** `Nesting | MediaRangeSyntax` for Turbopack,
`Nesting` for Webpack. User `include` is OR-ed on top, user `exclude`
masks bits off.

**Feature names:** 21 individual features (bit 0–20) + 3 composite
groups (`selectors`, `media-queries`, `colors`), all in dash-case.

### Test

- **Include test**
(`test/e2e/app-dir/experimental-lightningcss-features/`) — targets
Chrome 123 (which natively supports `light-dark()`) with `include:
['light-dark']`, then asserts the CSS output contains lightningcss
transpilation markers (`--lightningcss-light`, `--lightningcss-dark`)
instead of raw `light-dark()`.
- **Exclude test**
(`test/e2e/app-dir/experimental-lightningcss-features-exclude/`) —
targets Chrome 100 (which does NOT support `light-dark()` natively) with
`exclude: ['light-dark']`, then asserts the CSS output preserves raw
`light-dark()` calls and does not contain transpilation markers.
2026-03-11 08:06:52 +01:00
Joseph 69f53fd971 docs: Streaming guide (#90779)
- [x] update links to demo
- [x] minor polishing identified by AI
- [x] update links (dep: docs-unify-caching-story)
- [x] check the implementation details vs actionable info balance
- [x] how (and when) to block streaming?
https://github.com/vercel/next.js/pull/90450
- [x] INP and the hydrate me later trick link to demo

---------

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
2026-03-10 20:59:22 +01:00
Joseph 3162af8dff docs: More Server Actions security guidance across docs (#90878)
Closes:
https://linear.app/vercel/issue/DOC-6108/server-action-security-lift
2026-03-10 20:59:03 +01:00
Steven bfb8cc7ab3 chore(docs): mention behavior of redirects and remotePatterns (#91151)
Some users have been confused by the relationship of
`images.remotePatterns` and `images.maximumRedirects` so lets document
it.

This behavior is expected since you might allowlist something like
`https://github.com/styfle.png` and that can redirect to whatever it
needs to redirect to (assuming maximumRedirects > 0). For example, it
currently redirects to
`https://avatars.githubusercontent.com/u/229881?v=4` but you can imagine
in the future if the redirect was changed, you wouldn't want your app to
break.

Regardless of redirects, the final response must be an image.

---------

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2026-03-10 12:41:49 -04:00
Ethan (Taehoon) Lee 5e4a54ea39 docs(localFont): enhance details about using the localFont function (#88189)
### What?
Enhance the documentation about how to use the `localFont` function.

### Why?
The Next.js documentation about [local
fonts](https://nextjs.org/docs/app/getting-started/fonts#local-fonts)
has insufficient information about where to store the font files and how
to reference them with the `localFont` function. The lack of detail
causes confusion like this issue:
https://github.com/vercel/next.js/issues/76573.

### How?
I created a [demo](https://nextjs-localfont-demo.vercel.app/) to
investigate the behavior of the `localFont` function (source:
https://github.com/ethn1ee/nextjs-localfont-demo). I confirmed that the
font files can be located anywhere inside the project, including at
root, the `src` directory, the `app` directory, and the `public`
directory, and that they must all be referenced using relative paths.

Fixes #76573

---------

Co-authored-by: Ethan Lee <48551278+ethn1ee@users.noreply.github.com>
Co-authored-by: Joseph <sephxd1234@gmail.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-03-09 13:20:31 +01:00
Tim Neutkens b3a587e970 Update adapters documentation (#90986)
## What?

Updates the adapters docs with missing fields and more details

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-03-06 21:24:01 +01:00
JJ Kasper d2525d765a docs: explain deploy test custom scripts (#90966)
## Summary
- document how to use custom deploy, logs, and cleanup scripts with the
deploy test workflow
- describe the expected stdout/log marker contract for custom scripts
- keep the examples generic to adapter implementations

---------

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2026-03-06 13:26:10 +01:00
Joseph 75af3bbd28 Uncached data suspense issue (#90450)
<!-- 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


## 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?
Added a new section "Opting Into Fully Dynamic Rendering" to
`errors/blocking-route.mdx`.

### Why?
To surface the "Suspense over body" pattern as a general solution for
"Uncached data or connection() was accessed outside of <Suspense>"
errors. This pattern was previously only documented in
`next-prerender-dynamic-viewport.mdx` but is relevant to all blocking
route errors, providing a clear opt-out for users who want fully dynamic
rendering without granular Suspense boundaries. This directly addresses
a common user query.

### How?
Added a new section with a code example demonstrating wrapping the root
`<html>` in `<Suspense>` within `app/layout.tsx`.

Closes NEXT-
Fixes #

-->

---
[Slack
Thread](https://vercel.slack.com/archives/C07BS1WEYAZ/p1771948980142259?thread_ts=1771948980.142259&cid=C07BS1WEYAZ)

<p><a
href="https://cursor.com/agents/bc-a1a4ed9d-03cd-4241-b057-748fbf9487a9"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-a1a4ed9d-03cd-4241-b057-748fbf9487a9"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</p>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Joseph <icyJoseph@users.noreply.github.com>
2026-03-05 14:58:15 +01:00
Jimmy Lai dfbc3dc6b7 Loading layout docs update (#90787)
<!-- 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


## 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?
This PR updates the documentation to clarify the interaction between
`loading.js` and `layout.js`.

### Why?
To address a common point of confusion and potential blocking navigation
issues when layouts are dynamic. It provides clear guidance on how
`loading.js` behaves relative to layouts and how to use `<Suspense>` for
dynamic layout parts.

### How?
- Added a "Good to know" callout in `loading.mdx` explaining that
`loading.js` does not wrap the layout.
- Introduced a new "Interaction with `loading.js`" section under Caveats
in `layout.mdx`, including an explanation and a code example for
wrapping dynamic layout components with `<Suspense>`.
- Added a brief "Good to know" callout in `fetching-data.mdx` for
consistency.

Closes NEXT-
Fixes #
-->

---
[Slack
Thread](https://vercel.slack.com/archives/C05KYT5S9FF/p1772239839900129?thread_ts=1772239839.900129&cid=C05KYT5S9FF)

<p><a
href="https://cursor.com/agents/bc-d69fb736-2a00-5f68-9e28-9b31c194f12a"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-d69fb736-2a00-5f68-9e28-9b31c194f12a"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</p>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Joseph Chamochumbi <joseph.chamochumbi@vercel.com>
Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
2026-03-05 10:46:26 +01:00
Hichem 11c906a75c update proxy docs to use NextProxy type (#90647)
### What?
Updated all proxy code examples in the API reference to use the
`NextProxy` typed arrow function pattern, consistent with the convention
used in `src/proxy.ts`.

### Why?
The proxy function is typed as `NextProxy` so parameters are inferred
from the type, removing the need for explicit `NextRequest` imports.

### How?
Updated all proxy code examples in the API reference to use the
`NextProxy` typed arrow function pattern, consistent with the convention
used in `src/proxy.ts`.

---------

Co-authored-by: Joseph <sephxd1234@gmail.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-03-04 10:39:34 +01:00
Sebastian "Sebbie" Silbermann 296e180036 Add transitionTypes prop to next/link (#90701)
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-03-03 18:46:19 +00:00
Delba de Oliveira c2b4c0815c Unify caching story across the docs (#90149)
This PRs unifies the caching story across the docs, making Cache
Components the happy path, while still providing guidance to users in
the old model. However, instead of explaining the old model and its
caching layers, we've created a new guide focusing on what APIs to use
and when.

This follow-up PR aligns terminology across the docs:
https://github.com/vercel/next.js/pull/90589

## IA updates

Getting Started section: 

- Improves Getting Started progression:
- **Before:** CC → Fetching Data → Updating Data → Caching and
Revalidating (old and new model mixed)
- **After:** Fetching Data (Dynamic) → Mutating Data (Dynamic) → Caching
with CC (Prerendering) → Revalidating with CC.
- New: `caching.mdx` (CC-first)
   - Structure: 
      - Enabling Cache Components
      - Data vs UI-level caching
      - Working with request time APIs
      - Passing request values to cached functions
      - Working with non-deterministic operations
      - Working with synchronous operations
      - How rendering works (PPR and static shell story)
- New: `revalidating.mdx` (CC-first)
   - Explains how to use `cacheLife` and `cacheTag`

Guides Section: 

- New: `caching-and-revalidating.mdx` (Previous Model)
- For users who are not using CC, includes `fetch` options and route
segment config
- Moves route segment config options that don't apply to CC from API
reference to this guide (for easy archiving in the future).
- New: `migrating-to-cache-components.mdx` (WIP)
- Del: `caching.mdx` 😌 

## Terminology

We should remove caching layers from the docs. Users only needed to be
exposed to them when they were configured independently, but the new CC
APIs work across layers.

To make it easier to review this PR, I'm consolidating terminology and
fixing broken links in a new PR:
https://github.com/vercel/next.js/pull/90589

---------

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-03-03 13:14:24 +00:00
Joseph 872c01b5e6 Create next app CLI docs (#90788)
<!-- 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


## 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?
Updated `installation.mdx` and `create-next-app.mdx` documentation.

### Why?
To accurately reflect the `create-next-app` CLI's behavior regarding
`AGENTS.md` and `CLAUDE.md` file generation, and to update the displayed
default configuration.

### How?
- **`docs/01-app/01-getting-started/01-installation.mdx`**:
- Updated `--yes` flag description to mention `AGENTS.md` and
`CLAUDE.md` inclusion.
- Corrected the recommended defaults prompt to replace "Turbopack" with
"AGENTS.md".
    - Added the `AGENTS.md` prompt to the customize settings section.
- **`docs/01-app/03-api-reference/06-cli/create-next-app.mdx`**:
    - Added `--agents-md` flag to the options table.
    - Updated recommended defaults and customize settings prompts.

Closes NEXT-
Fixes #

-->

---
[Slack
Thread](https://vercel.slack.com/archives/C07BS1WEYAZ/p1772483393984349?thread_ts=1772483393.984349&cid=C07BS1WEYAZ)

<p><a
href="https://cursor.com/agents/bc-2f6bce63-8c1b-544a-9a10-cb65f56b213d"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-2f6bce63-8c1b-544a-9a10-cb65f56b213d"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</p>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Joseph <icyJoseph@users.noreply.github.com>
2026-03-03 09:54:10 +01:00
Jiwon Choi cbb2f90e97 docs: error component unstable_retry() (#89732)
Adding docs for https://github.com/vercel/next.js/pull/89685
2026-03-02 17:43:56 +01:00
Abhishek Mardiya 99b26351a5 docs: clarify native <script> usage for JSON-LD in docs (#90380)
While reviewing the [JSON-LD
documentation](https://nextjs.org/docs/app/guides/json-ld ), I noticed
that seeing `<script>` instead of `<Script>` can easily feel like a typo
> Our current recommendation for JSON-LD is to render structured data as
a <script> tag in your layout.js or page.js components.

This PR adds a short clarification explaining why the native `<script>`
tag is intentionally recommended for JSON-LD. The goal is to reduce
confusion and make the guidance clearer for developers reading the docs.

@icyJoseph

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-03-02 14:26:12 +01:00
Joseph 080e1b3c26 Accept header content negotiation (#90607)
<!-- 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


## 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?
Added a new "Content negotiation" subsection to the Backend For Frontend
(BFF) guide.
Updated the `related` links in the frontmatter of the BFF guide to
include "rewrites".

### Why?
To document how to implement content negotiation using Next.js rewrites
and Route Handlers, specifically for serving different content types
(e.g., Markdown) based on the `Accept` header. This includes explaining
the role of the `Vary: Accept` header for correct caching behavior.

### How?
A new subsection was added to
`docs/01-app/02-guides/backend-for-frontend.mdx`.
The section includes a `next.config.js` rewrite example using `has` to
match the `Accept` header.
A corresponding Route Handler example (`app/docs/md/[...slug]/route.ts`)
demonstrates serving Markdown content.
The documentation explains the `Vary: Accept` header and its
implications for caching.
The `related` links in the frontmatter were updated to point to the
rewrites documentation.

Closes NEXT-
Fixes #

-->

---
[Slack
Thread](https://vercel.slack.com/archives/C07BS1WEYAZ/p1772118031912479?thread_ts=1772118031.912479&cid=C07BS1WEYAZ)

<p><a
href="https://cursor.com/agents/bc-2c93f44d-958d-5c0b-abe0-a2b36aa76f19"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-2c93f44d-958d-5c0b-abe0-a2b36aa76f19"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</p>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Joseph <icyJoseph@users.noreply.github.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
2026-02-27 19:31:22 +01:00
Mimori 15fcfb9ce4 docs: fix navigationType value and variable name in useReportWebVitals (#90599)
## For Contributors

### Improving Documentation

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

### What?

Fix two bugs in the `useReportWebVitals` API reference docs:

1. `navigationType` value `"back_forward"` → `"back-forward"`: the
`web-vitals`
library intentionally renames this value to use a hyphen for
consistency.
2. Variable name mismatch in `handleCustomMetrics` example: parameter
was named
`metrics` (plural) but the function body referenced `metric.name`
(singular),
   causing a `ReferenceError`.

### Why?

The `navigationType` description reflected the raw
`PerformanceNavigationTiming`
API value (`"back_forward"`), not the actual value emitted by the
`web-vitals`
library (`"back-forward"`), which `useReportWebVitals` is built on top
of
Ref: https://github.com/GoogleChrome/web-vitals?tab=readme-ov-file#types

The variable name mismatch in the code example would cause a
`ReferenceError`
if copied as-is.

### How?

- Updated `navigationType` description to use `"back-forward"`.
- Renamed parameter `metrics` → `metric` in the `handleCustomMetrics`
example

---------

Co-authored-by: Joseph <sephxd1234@gmail.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-02-27 15:10:29 +01:00
agneliutkiene bb813afd49 docs(deploying): add Hostinger Web Apps Hosting to Node.js deployment options (#90246)
This proposal adds Hostinger Web Apps Hosting as one additional
deployment option in existing deployment documentation.

- Keeps language provider-neutral
- No runtime or code behavior changes
- Keeps current structure and recommendations intact

Link used: https://github.com/hostinger/deploy-nextjs

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-02-27 12:51:31 +01:00
Joseph 05b0690356 feat: Join guides and frame around UI preservation (#90595)
As we discussed, let's scale back how much Activity we teach and focus
on UI preservation, choice of pattern, and wrap it all with a demo where
these are implemented.

- [x] rename file

---------

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
2026-02-26 16:18:36 +01:00
Kristiyan Velkov ae79ae55eb docs: add Docker Standalone and Docker Export examples to Deploying page (#90386)
### What?

Updates the
[Deploying](https://nextjs.org/docs/app/getting-started/deploying) page
Docker section to document the new and updated Docker examples and add
description to old ones.

### Why?

The Docker examples were added/updated in
[#87069](https://github.com/vercel/next.js/pull/87069). The Deploying
page still only listed the generic "Docker" and "Docker
Multi-Environment" templates, so the new **Docker Standalone** and
**Docker Export** examples were not discoverable from the docs.

### How?

- Add **Docker Standalone** template linking to `examples/with-docker`
(`output: "standalone"` for minimal container images).
- Add **Docker Export** template linking to
`examples/with-docker-export-output` (`output: "export"` for static HTML
in a container).
- Order templates as: Docker Standalone, Docker Export, then Docker
Multi-Environment.

---

**Related:** This PR follows up on the merged [PR
#87069](https://github.com/vercel/next.js/pull/87069) (Docker examples
for standalone and export output). It updates the docs so the Deploying
page links to those examples.

---------

Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
Co-authored-by: kristiyan.velkov <kristiyan.velkov@ffw.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-26 14:51:59 +01:00
Joseph 9192de431b docs: update with more patterns and decision based (#90203)
Adding useActionState reset pattern, and reframing some of the
recommendations as a choice.

---------

Co-authored-by: Ismael <ismael@vercel.com>
2026-02-24 19:11:23 +01:00
Karl Horky da0cbcce76 Add not-found.js / notFound() links to Status Codes section (#88332)
<!-- 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


## 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 #

-->

### What?

Add links to the helpful [Status Codes section of the `loading.js` docs
page](https://nextjs.org/docs/app/api-reference/file-conventions/loading#status-codes)
from the
[`not-found.js`](https://nextjs.org/docs/app/api-reference/file-conventions/not-found)
and
[`notFound()`](https://nextjs.org/docs/app/api-reference/functions/not-found)
docs pages

### Why?

To avoid misunderstandings that the streamed HTTP 200 responses are
negatively affecting SEO, as posited in such articles:

-
https://matthewmorek.com/journal/how-to-fix-next-js-notfound-returning-200-ok-with-app-router-and-suspense

It is mentioned in the `loading.js` docs as well as @ztanner's comment
here:

- https://github.com/vercel/next.js/issues/45801#issuecomment-2104816811

But not yet on the `not-found.js` or `notFound()` docs pages:

<img width="1439" height="629" alt="Screenshot 2026-01-09 at 17 16 24"
src="https://github.com/user-attachments/assets/5a2c9edf-1c28-4ae5-ab6e-08ac5ea703f7"
/>
<img width="1440" height="538" alt="Screenshot 2026-01-09 at 17 16 41"
src="https://github.com/user-attachments/assets/e83d3dbd-b175-4375-8aa2-311744d2daf2"
/>


### How?

Add some small edits

### Alternatives considered

1. Duplicating the Status Codes content to the `not-found.js` and
`notFound()` pages so it's accessible in all 3 places
   1. Copying and pasting the whole section
2. Making it a "partial" or "include" which can be used in both places
2. Moving the "Status Codes" (and maybe "SEO") section(s) out of the
`loading.js` page into a separate docs page

But both of those options require a bit more work and thinking.

---------

Co-authored-by: Joseph <sephxd1234@gmail.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-02-24 18:08:27 +01:00
Joseph dcf11d111b docs: clarify that next upgrade is for 16.1.x+ (#90435)
Closes: https://github.com/vercel/next.js/issues/90425
2026-02-24 17:50:03 +01:00
Mary Lavanitha d13d1ba23b docs: improve form guide consistency and validation examples (#90361)
### What?
Small improvements to the Forms guide for consistency and clarity.

### Why?
Some examples didn’t fully match the recommendations in the guide (e.g.
HTML validation), and there was a minor inconsistency between
`event.target` and `event.currentTarget`. This update keeps the examples
aligned and easier to follow.

### How?
- Added `required` to relevant input examples  
- Standardized usage of `event.currentTarget`  
- Made minor wording refinements for clarity

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-02-24 10:45:04 +01:00
Tyler Arthur c23f3434a3 docs: fixes typo in manifest.mdx regarding Route Handler note (#90394)
This PR fixes a typo in the docs about the manifest.js file

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-02-23 23:52:45 +01:00
Jimmy Lai fe0bb2fc51 Next.js sticky scroll standards (#90197)
<!-- 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

- [x] Run `pnpm prettier-fix` to fix formatting issues before opening
the PR.
- [x] 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


## 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 #

-->
### What?
Adds documentation for handling sticky headers with Next.js navigation
using `scroll-padding-top`.

### Why?
Next.js's auto-scroll behavior explicitly skips sticky and fixed
positioned elements. This can cause content to appear behind sticky
headers when navigating to a hash fragment or using the `scroll` prop on
`Link`. This documentation provides a web-standards solution using CSS
`scroll-padding-top` to correctly position the scroll target.

### How?
- Added a new "Handling sticky headers with `scroll-padding-top`"
subsection to the `Link` component API reference
(`docs/01-app/03-api-reference/02-components/link.mdx`) under the
`scroll` prop.
- Added a new "Scrolling with sticky headers" example to the "Linking
and Navigating" guide
(`docs/01-app/01-getting-started/04-linking-and-navigating.mdx`).

---
[Slack
Thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1771434038077029?thread_ts=1771434038.077029&cid=C03KAR5DCKC)

<p><a
href="https://cursor.com/background-agent?bcId=bc-cc4b24d5-0e73-5b36-84a3-f40e65064f7c"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/agents?id=bc-cc4b24d5-0e73-5b36-84a3-f40e65064f7c"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a></p>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Joseph Chamochumbi <joseph.chamochumbi@vercel.com>
2026-02-23 10:38:22 -08:00
Abhishek Mardiya 757ab17e54 In-Depth Explanation of React Version Handling Doc (#89426)
There have been multiple discussions and some confusion around [React
version handling](https://nextjs.org/docs#react-version-handling) in
Next.js. This PR adds an in-depth explanation to clarify how React and
react-dom versions are managed internally, and why they still need to be
declared in package.json.

The goal is to help developers better understand this behavior and
reduce recurring questions around it.

Reference discussion:
https://github.com/vercel/next.js/discussions/87958

@icyJoseph

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Joseph <sephxd1234@gmail.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-02-23 10:40:10 +01:00
Steven 39eb8e0ac4 feat(next/image): add lru disk cache and images.maximumDiskCacheSize (#89963)
This PR adds an LRU disk cache so that reads and writes from the Image
Optimization API will evict old entries based on the value of
`images.maximumDiskCacheSize` configuration.

The LRU ensures that cache reads bump the entry to the top so that they
don't get evicted - only the least recently used entries get evicted.

When `next start` is run, if there is an existing disk cache the we will
replay the files in order to populate the LRU and respect
`images.maximumDiskCacheSize` if it was changed.

If no configuration is provided, default to 50% available disk space.
2026-02-20 20:12:26 +00:00
Jude Gao 104f0db376 [Docs] Add AGENTS.md and bundled docs guide (#89973)
Adds a guide for configuring AI coding agents to use the version-matched
documentation bundled in `node_modules/next/dist/docs/` (shipped via the
`copy_docs` build task in #89850) instead of stale training data.

The guide covers how the bundled docs work, the `AGENTS.md` and
`CLAUDE.md` files generated by `create-next-app --agents-md`, and how to
add project-specific instructions outside the `<!--
BEGIN:nextjs-agent-rules -->` markers.
2026-02-16 10:51:01 -08:00
Swarnava Sengupta ababa1b3d9 docs: clarify async instrumentation register request (#90039)
Explicitly document that Next.js waits for an async instrumentation
register function to complete before handling incoming requests, and
align wording between the guide and API reference.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-02-16 12:04:01 +01:00
Andrew D'Amelio 40b9243594 docs: fix broken blockquote formatting in API Routes page (#89966)
The second and third bullet points in the 'Good to know' callout were
incorrectly placed outside the blockquote, breaking the visual grouping
on the rendered documentation page.

<!-- 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


## 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 #

-->

Co-authored-by: Andrew Damelio <andrewdamelio@users.noreply.github.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-02-14 01:31:20 +01:00
Tobias Koppers 740d55cdce Turbopack: Add inline loader configuration via import attributes (#89644)
## What?

Adds support for inline loader configuration in Turbopack via import attributes. Developers can apply webpack-compatible loaders to individual imports using the `with` clause, without needing global `turbopack.rules` configuration.

```tsx
import rawText from '../data.txt' with { turbopackLoader: 'raw-loader', turbopackAs: '*.js' }
import value from '../data.js' with {
  turbopackLoader: 'string-replace-loader',
  turbopackLoaderOptions: '{"search":"PLACEHOLDER","replace":"replaced value"}'
}
```

## Why?

Global `turbopack.rules` applies loaders to all files matching a pattern. This PR provides per-import granularity — useful when only a specific import needs special treatment, avoiding side effects on other imports of the same file type.

## How?

### Import attributes parsing (`turbopack-ecmascript/src/analyzer/imports.rs`)
- Extended `ImportAnnotations` to parse four new attributes: `turbopackLoader`, `turbopackLoaderOptions`, `turbopackAs`, `turbopackModuleType`
- All values are strings per TC39 import attributes spec (`turbopackLoaderOptions` is a JSON-encoded string)
- Added unit tests for the parser

### New structured loader type (`turbopack-core/src/loader.rs`)
- Added `WebpackLoaderItem` struct shared between inline and global loader paths

### Reference type plumbing (`turbopack-core/src/reference_type.rs`, `turbopack-ecmascript/src/references/esm/base.rs`)
- Added `ImportWithTurbopackUse` variant to `EcmaScriptModulesReferenceSubType` carrying the parsed loader, rename_as, and module_type
- ESM reference resolution maps the parsed annotations to this new subtype

### Loader execution (`turbopack/src/lib.rs`)
- In `process_default_internal`, detects `ImportWithTurbopackUse` references and applies the loader as a source transform via the existing webpack loader infrastructure
- Requires `enable_webpack_loaders` to be configured (same as global rules)
- Supports `turbopackAs` (re-processes with new extension) and `turbopackModuleType` (directly sets module type)
- Avoids infinite recursion by switching to plain `Import` reference type on re-processing

### Documentation (`docs/.../turbopack.mdx`)
- Added section documenting the four import attributes with examples
- Added version history entry for v16.2.0

### Testing (`test/development/app-dir/turbopack-import-assertions-use/`)
- E2e test covering raw loader, replace loader with options, `turbopackModuleType: 'ecmascript'`, and `turbopackModuleType: 'json'`
- Turbopack-only (skipped for webpack)
2026-02-13 19:45:10 +01:00