Commit Graph

3804 Commits

Author SHA1 Message Date
Joseph 4001cc9546 docs: use cache feedback (#85169) 2025-10-22 12:51:56 +02:00
Joseph 4cae094393 docs: cache components - introduction (#85196) 2025-10-22 12:41:45 +02:00
Joseph 56136287eb docs: create-next-app react-compiler and new prompts (#85213)
update the create-next-app options and prompts
2025-10-22 11:00:04 +02:00
Joseph 48bb490d63 docs: upgrade from 15 to 16 (#85176)
Co-authored-by: Ismael <ismael@vercel.com>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2025-10-22 00:10:29 +02:00
Joseph 400b82cb45 docs: remove experimental_ppr route segment config (#85188)
Removed on v16
2025-10-21 20:57:10 +02:00
JJ Kasper 7a8019599e Update routes generation for build-complete (#85017)
## Summary

- Adds comprehensive route generation and normalization for
build-complete adapter hooks
- Enhances adapter output types with additional metadata fields
(`sourcePage`, `wasmAssets`, `pprChain`, `parentFallbackMode`)
- Improves middleware matcher handling and revalidation bypass logic
- Adds proper tracing for shared node dependencies across pages and app
router modules
- Includes `buildId` in adapter context for build identification

## Changes

### Route Generation
- Generates complete route manifests with processed regex patterns for
headers, redirects, rewrites, and dynamic routes
- Converts routes using `@vercel/routing-utils` for consistent
formatting
- Handles RSC routes (`.rsc` suffix) for app router pages
- Supports i18n locale-specific routes and data routes
(`/_next/data/[buildId]/...`)
- Properly handles static pages with mixed app/pages router setups

### Adapter Output Enhancements
- Added `sourcePage` field to all route outputs for tracking original
source files
- Added `wasmAssets` support for bundled WebAssembly files
- Added `pprChain` and `parentFallbackMode` to prerender outputs for PPR
support
- Enhanced middleware matchers to include processed source and regex
patterns
- Improved traced assets handling with separate tracking for pages vs
app router modules

### Middleware & Revalidation
- Standardized middleware matcher format with `source`, `sourceRegex`,
`has`, and `missing` fields
- Automatically adds `x-prerender-revalidate` header bypass to
middleware matchers
- Fixed middleware pathname to always be `/_middleware` for consistency

### Asset Tracing
- Traces shared node dependencies for bootstrapping (node-environment,
require-hook, etc.)
- Separate tracing for pages router and app router module contexts
- Improved trace ignores for unnecessary files (dev builds, webpack
internals, etc.)
- Better handling of instrumentation hook assets

### Bug Fixes
- Fixed RSC fallback handling for mixed app/pages router builds
- Improved 404/500 static page detection with locale support
- Better basePath normalization with trailing slash handling
- Fixed data route generation for getServerSideProps pages with i18n
2025-10-21 10:21:25 -07:00
Tim Neutkens 08d679c23d Docs: Explain Sass tilde import difference (#85041) 2025-10-21 18:44:47 +02:00
Jiachi Liu 30503c149b docs: mcp (#85010)
Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-10-21 08:25:01 -07:00
Luke Sandberg daf8b06f68 [turbopack] Remove the canary icon from the cache components docs (#85149)
Its not canary anymore.
2025-10-20 20:11:44 -07:00
Jiwon Choi 2cc5f0227b Add Learn more docs to Middleware deprecation warning (#84711)
This PR adds an error doc for the Middleware deprecation warning that it
can refer to.

  - Explain why this error occurred
  - Provide migration guide
  - Explain the rationale for the renaming to Proxy

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
2025-10-20 19:26:30 -07:00
Wyatt Johnson 3f8febe2b5 docs: Added documentation for "use cache: private" (#85038)
Added documentation for `use cache: private`.

---------

Co-authored-by: Joseph Chamochumbi <joseph.chamochumbi@vercel.com>
2025-10-20 18:03:45 -06:00
Delba de Oliveira ca7f57ee2d Docs: Add version history for next lint deprecation and update error message (#85100)
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-10-20 19:58:07 +00:00
Maxim 43eeb928e6 docs: Update to Zod v4 syntax (#84807)
### What?
Updated Zod syntax to v4 conventions in documentation examples.

### Why?
Zod 4 deprecates `message` parameter in favor of `error`, and string
format methods like `.email()` in favor of top-level functions like
`z.email()`.

### How?
- Replaced `{ message: '...' }` with `{ error: '...' }` 
- Changed `z.string().email()` to `z.email()`

---------

Co-authored-by: Maxim Andriushin <maksim.andriushin@gmail.com>
Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-10-20 21:26:52 +02:00
Joseph ada92f761e docs: no switcher for TS only examples (#85109) 2025-10-20 20:01:30 +02:00
Delba de Oliveira 4955c5dd6b Docs: Add note on tag limits for cacheTag (#85106) 2025-10-20 14:40:07 +01:00
Delba de Oliveira 02c9a7ede4 Docs: Add --debug-build-paths next build option (#85097)
Related: https://github.com/vercel/next.js/pull/85052
2025-10-20 14:40:00 +01:00
Joseph 27862f0065 docs: experimentalClientMaxBodySize (#85105)
The experimental "nature" of the flag is reflected in the version
2025-10-20 15:11:38 +02:00
Tim Neutkens 0f09c40ac9 Turbopack: Better error for sassOptions.functions as it's unsupported (#85073)
## What?

Implements an error for the case where Turbopack is used with
sassOptions.functions.

Fixes #65241
2025-10-19 14:45:40 -07:00
Zack Tanner 1b949df737 [cache components] stabilize cacheLife profiles (#85050)
As part of stabilizing `cacheComponents`, `cacheLife` profiles should
also be accessible from a top-level config. This updates the
configuration, adds the warning, and updates relevant docs.
2025-10-18 18:50:00 -07:00
Zack Tanner 85c3d20a91 [cache components]: move flag out of experimental (#85035)
This moves `experimental.cacheComponents` to a top level config. As part
of this, I disabled some tests in `build-output-prerender` that assert
on `cacheComponents` appearing in the experimental list. In a separate
PR, I'm going to show that Cache Components is enabled next to the
bundler info.

This also updates some docs pages to remove "experimental" language.
2025-10-18 14:13:44 -07:00
Jiwon Choi b4080311f4 [Breaking] Rename instrumentation onRequestError context.routeType from middleware to proxy (#85006)
Follow up on https://github.com/vercel/next.js/pull/84710,
`instrumentation` docs had `onRequestError` function's param
`context.routeType` has value of `'middleware'`. As it's a user-facing
value, update it to `'proxy'`.
2025-10-17 23:31:24 +02:00
Jiwon Choi bbfcbe9611 Rename MiddlewareMatcher to ProxyMatcher (#85005)
Follow up on https://github.com/vercel/next.js/pull/84710, `adapterPath`
docs had `MiddlewareMatcher` type, used in `ProxyConfig` type. As it's a
user-facing type, update it.
2025-10-17 23:29:53 +02:00
Janka Uryga bae8bf4606 [Cache Components] fix docs for cacheLife("seconds") (#85004)
Looks like this was missed in #82332, when we bumped the staletime to
30s.
2025-10-17 23:09:58 +02:00
Jiwon Choi bc59f210b0 docs: Deprecation of Middleware (#84710)
This PR removes middleware docs and adds a "Migration to Proxy" section
to the Proxy docs, which explains the rationale for the renaming to
Proxy and provides a migration guide.

Did not remove `middleware-upgrade-docs` as it's an upgrade doc from the
legacy middleware.

Below are untouched as they need codebase changes:

- `instrumentation` docs - `onRequestError` has `context.routeType` as
`'middleware'`
- `adapterPath` docs - has `MiddlewareMatcher` type example
- `ProxyConfig` - has a user-facing `MiddlewareMatcher` type

---------

Co-authored-by: Joseph Chamochumbi <joseph.chamochumbi@vercel.com>
2025-10-17 20:03:13 +02:00
Jiwon Choi 71ce95dffa docs: Replace Middleware docs to Proxy (#84709)
> [!NOTE]
> Best reviewed by each commit for better diff view.

This PR clones the Middleware docs for Proxy and removes the Middleware docs.

Did not clone the list of docs:

- `errors/middleware-upgrade.mdx` - It's a middleware upgrade guide from v12.2
- `errors/beta-middleware.mdx` - It's an error when using middleware before v12.2
- `errors/returning-response-body.mdx` - Legacy behavior from versions < v12.2
2025-10-17 16:13:26 +02:00
Jiwon Choi fd8b4c5979 docs: Split "Get Started: Route Handlers and Middleware" to Route Handlers and Proxy (#84708)
This PR splits the route handlers and middleware to allow for separate
onboarding docs, making it easier to migrate the docs from Middleware to
Proxy.

These PR stacks are to publish a full replacement of the docs for the
Middleware to Proxy. Steps are as follows:

- Split "Get Started: Route Handlers and middleware" to Route Handlers /
Proxy
- Clone the Middleware docs for Proxy
- Add "Migration to Proxy" section to Middleware docs
  - Explain the rationale for the renaming to Proxy
  - Provide migration guide
- Add an error doc that the deprecation warning can refer to. The error
doc will:
  - Explain why this error occurred
  - Provide migration guide
  - Explain the rationale for the renaming to Proxy
2025-10-17 16:00:14 +02:00
Joseph 332aaf3939 docs: getting started installation and next lint removal (#84781)
- [x] verify rendering of the changes

Also addressing: #84772

---------

Co-authored-by: Jiwon Choi <devjiwonchoi@gmail.com>
2025-10-17 15:39:21 +02:00
Muhammad Rohan Hussain 7296aa624e Update prefetching.mdx providing more clarity on the usage of router.prefetch() (#84903)
## What
Updated `prefetching.mdx` in the App Router documentation providing more
clarity on the usage of `router.prefetch()`.

## Why
We found the current section on `Manual Prefetching` to be lacking in
detail and a bit misleading as well.

The issue with the current version of the documentation is that the code
snippet provided:
```tsx
const router = useRouter();
router.prefetch();
```
Makes it seem like `router.prefetch()` can be called at the same level
as `useRouter()`, i.e. in the component body, even though that causes
the page to crash for many possible reasons, such as `window is not
defined`, or `Router action dispatched before initialization.`.

I am not sure if this is helpful/correct or not, just thought this may
help someone. If not feel free to close this PR. Thanks in advance for
your time.

## Reproduction
Here is a codesandbox reproducing the issue that occurs if you follow
the code snippet trivially:
https://codesandbox.io/p/devbox/s5pmsj

<!-- 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. (Done)
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide (Done)


Closes NEXT-
Fixes #

-->

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2025-10-17 15:20:22 +02:00
Jiwon Choi 8bc8dc343c docs: Add missing codemod docs (#84980)
- middleware-to-proxy
- remove-unstable-prefix
2025-10-17 13:20:17 +02:00
Jiwon Choi b42555aa39 Add codemod for removing experimental_ppr (#84979)
`experimental_ppr` is removed by
https://github.com/vercel/next.js/pull/84871, so add codemod for it.
2025-10-17 03:45:02 +02:00
Joseph 828211efa1 docs: Templates on navigation (#84493)
The docs on Template and its life cycle, were not that clear.

Closes:
https://linear.app/vercel/issue/DOC-5107/review-templates-api-reference

---------

Co-authored-by: Ismael <ismael@vercel.com>
2025-10-17 00:45:30 +02:00
Joseph 45fcbdea7a docs: x-nextjs-stale-time header (#84901)
Let's add a note about this header.

-
https://github.com/vercel/next.js/blob/3ae7ace09338bcde92ececb6b03a03760f302aed/packages/next/src/server/app-render/app-render.tsx#L2076-L2079

-
https://github.com/vercel/next.js/blob/3ae7ace09338bcde92ececb6b03a03760f302aed/packages/next/src/client/components/segment-cache-impl/cache.ts#L262-L268

-
https://github.com/vercel/next.js/blob/3ae7ace09338bcde92ececb6b03a03760f302aed/packages/next/src/client/components/segment-cache-impl/cache.ts#L318-L326

---------

Co-authored-by: Ismael <ismael@vercel.com>
2025-10-17 00:45:09 +02:00
Joseph c2863c8724 Docs/sync with new features 0 (#84861)
Sync w/ isolatedDevBuild and updateTag+revalidatePath/Tag

---------

Co-authored-by: Rich Haines <hello@richardhaines.dev>
2025-10-16 19:31:24 +00:00
Zack Tanner 014228f097 stabilize experimental.enablePrerenderSourcemaps (#84916)
As part of stabilizing cacheComponents, we are also stabilizing
supporting flags. This flag has been enabled with cacheComponents for
some time and so we are moving it out of experimental.

It will continue to be enabled by default if you are using
cacheComponents. Otherwise, it can be opted into independently via next
config.

Closes https://linear.app/vercel/issue/NDX-1048
Closes https://github.com/vercel/next.js/pull/80317

---------

Co-authored-by: Sebastian "Sebbie" Silbermann <sebastian.silbermann@vercel.com>
2025-10-16 11:37:01 -07:00
Josh Story 76d2beaeb8 [Cache Components] Remove unstable prefix from unstable_cacheTag (#84880)
`cacheLife` is now stable and does not require an unstable prefix
2025-10-16 07:01:44 -07:00
Josh Story 8cab15c0c9 [Cache Components] Remove unstable prefix from unstable_cacheLife (#84877)
`cacheLife` is now stable and does not require an unstable prefix
2025-10-15 08:14:04 -07:00
Joseph 3ae7ace093 docs: next/dynamic headings (#84492)
Reworking and re-organizing the next/dynamic section - headings were not
consistent for Pages Router. The Pages router section also talked about
client and server components.
2025-10-15 14:09:20 +02:00
Luke Sandberg 17c99ca4e5 [turbopack] fix typo in docs (#84868)
https://github.com/vercel/next.js/pull/84837 merged a bit too quickly
2025-10-14 10:45:46 -07:00
Luke Sandberg 81b35a698c [turbopack] document missing webpack loader features (#84849)
This has come up a bit so we could attempt to be clear about it.
2025-10-14 10:24:53 -07:00
Luke Sandberg e36e29e3a7 [turbopack] Discuss Core Web vitals in our bundle size gap docs (#84837)
Core Web Vitals are generally a superior approach to web app perf, so we should mention them
2025-10-14 10:22:20 -07:00
Joseph cd524f57ec docs: soft 404's, Suspense and loading.tsx (#83867)
Closes: https://linear.app/vercel/issue/DOC-5089/soft-404s-in-the-docs

---------

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2025-10-14 12:36:55 +02:00
Luke Sandberg 37f4c793c9 [turbopack] Fix a few references to caching configuration as it is no longer canary guarded (#84761) 2025-10-10 12:46:14 -07:00
Luke Sandberg ee15207961 [turbopack] tweak the doc on the inner graph optimization (#84752)
This optimization is enabled by default and we already link to the docs so referencing the configuration option is more misleading than helpful.

Fixes https://github.com/vercel/feedback/issues/111264
2025-10-10 09:52:35 -07:00
Joseph a89f854f3e Revert "docs: nav_title for long unbroken words (#84233)" (#84346)
The pattern we use in other `config` metadata is to use the `config`
name.
2025-10-10 07:56:23 -07:00
Benjamin Woodruff 8f731e666f docs: Add more details to useLightningcss docs (#84581)
Adds a bit more context about the current state of the world.

Adds a warning if you set this to anything other than `undefined` on Turbopack:

![Screenshot 2025-10-09 at 4.18.02 PM.png](https://app.graphite.dev/user-attachments/assets/fbe4c8f5-6b1f-466c-953c-b16ae2f33751.png)
2025-10-09 18:48:46 -07:00
Zack Tanner b2ce9dd9c3 tweak middlewareClientMaxBodySize handling (#84712)
This ensures we captured `middlewareClientMaxBodySize` in the config
schema and rather than triggering a hard error, it will buffer up to the
limit.
2025-10-09 17:10:41 -07:00
Wyatt Johnson 3630146458 Add validation for missing default.js in parallel routes (#84702)
### What?

Adds build-time validation to require explicit `default.js` files for
all parallel route slots (except the implicit "children" slot). This
validation is implemented in both Webpack and Turbopack bundlers.

### Why?

Parallel routes without `default.js` files currently cause silent 404
errors when users navigate to those routes. This creates confusion and
hard-to-debug issues because the routes appear to be configured
correctly but fail at runtime without any indication of what went wrong.

By making this validation explicit at build time, developers get
immediate feedback about missing required files with clear error
messages and documentation links, catching configuration mistakes before
deployment.

### How?

**Rust/Turbopack** (`crates/next-core/src/app_structure.rs`): Added
`MissingDefaultParallelRouteIssue` that emits a build error when a
parallel route slot is missing its `default.js` file. The validation is
skipped for the "children" slot since it's implicit and doesn't require
a default file.

**Webpack**
(`packages/next/src/build/webpack/loaders/next-app-loader/index.ts`):
Added validation that throws `MissingDefaultParallelRouteError` when
`default.js` cannot be resolved. The "children" slot falls back to the
existing `PARALLEL_ROUTE_DEFAULT_PATH` behavior for backward
compatibility.

**Error Class**
(`packages/next/src/shared/lib/errors/missing-default-parallel-route-error.ts`):
New error type with helpful messaging that includes the slot path,
explanation of the requirement, and a link to documentation.

**Migration Path**: Users who want the previous 404 behavior can
explicitly create a `default.js` that calls `notFound()`, or return
`null` for empty slots:

```tsx
import { notFound } from 'next/navigation'

export default function Default() {
  notFound()
}
```

Users can also run the following Deno script to generate the default
files for them:
https://gist.github.com/wyattjoh/ba7263ecb637ef399d3e3e4db63ffbd6

**Breaking Change**: This is a breaking change timed for Next.js 16
beta. Builds will now fail if parallel route slots are missing required
`default.js` files.
2025-10-09 15:20:52 -06:00
JJ Kasper e598a4f976 Add new updateTag API and new signature for revalidateTag (#83822) 2025-10-09 14:03:01 -07:00
Steven 8d415853f7 [Breaking] feat(next/image)!: add support for images.dangerouslyAllowLocalIP and images.maximumRedirects (#84676)
This PR adds a two new options and sets a strict default value for each.

- `images.dangerouslyAllowLocalIP`
- `images.maximumRedirects`

### dangerouslyAllowLocalIP

In rare cases when self-hosting Next.js on a private network, you may
want to allow optimizing images from local IP addresses on the same
network.

However, this is not recommended for most users so the default is
`false`.

> [!NOTE]
> BREAKING CHANGE: This change is breaking for those who self-hosting
Next.js on a private network and want to allow optimizing images from
local IP addresses on the same network. In those cases, you can still
enable the config.

### maximumRedirects

Since are also testing redirects for local IPs, we can also reduce the
maximum number of redirects to 3 by default.

Unlike normal websites which might redirect for features like auth, its
unusual to have more than 3 redirects for an image.

In some rare cases, developers may need to increase this value or set to
`0` to disable redirects.

> [!NOTE]
> BREAKING CHANGE: This change is breaking for those who need image
optimization to follow more than 3 redirects.
2025-10-09 22:00:53 +02:00
Jiwon Choi 8041a382c9 [Breaking] Require images.localPatterns for query in Image src (#84406)
This PR modifies Image behavior to require `images.localPatterns.search`
value when used with search queries in the `src` property:

```jsx
// Error
<Image src="/api/user?id=1" width="50" height="50" />
```

```ts
// next.config.ts

export default {
  images: {
    localPatterns: [
      {
        pathname: '/api/user',
        // Either set explicit query string or leave undefined to match all
        search: '?v=2',
      },
    ],
  },
}
```

It is to prevent malicious actors like Denial of Wallet (DoW) attacks
and strictly match the search queries for image optimization.

The deprecation warning was added at
https://github.com/vercel/next.js/pull/82627

---------

Co-authored-by: Steven <steven@ceriously.com>
2025-10-09 21:01:42 +02:00