Unverified Commit 648110d4 authored by Joseph's avatar Joseph Committed by GitHub

docs: Add Pages Router upgrade guides for versions 15 and 16 (#100247)

## Summary

The Pages Router docs had no version 15 or 16 upgrade guides. This adds
both as `source:` stubs that render the App Router guides, and gates the
App Router-only sections with `<AppOnly>`.

- Version 15: Async Request APIs, `runtime` config, `fetch` caching,
Route Handlers, and Client Cache are App Router only. The React 19
minimum is App Router only; a `<PagesOnly>` bullet notes the Pages
Router supports React 18 and 19.
- Version 16: Async Request APIs, async metadata image and sitemap
params, React 19.2 (Canary), Caching APIs, routing and navigation, PPR,
parallel routes `default.js`, and the
`dynamicIO`/`useCache`/`unstable_rootParams` removals are App Router
only. Scroll Behavior Override stays shared (the Pages Router uses the
same helper) and gets a `pages/_document.tsx` example.
- App Router-only checklist items move to an `<AppOnly>` block at the
end of each checklist.

## Verification

- Not run: `prettier` (local install is broken; committed with
`--no-verify`, CI lint covers it)

<!-- NEXT_JS_LLM -->

🤖 Generated with [Claude Code](https://claude.com/claude-code)
parent 45e09fa4
......@@ -50,13 +50,26 @@ bun add next@latest react@latest react-dom@latest eslint-config-next@latest
## React 19
<AppOnly>
- The minimum versions of `react` and `react-dom` is now 19.
</AppOnly>
<PagesOnly>
- The Pages Router supports both React 18 and React 19, so upgrading `react` and `react-dom` to 19 is optional.
</PagesOnly>
- `useFormState` has been replaced by `useActionState`. The `useFormState` hook is still available in React 19, but it is deprecated and will be removed in a future release. `useActionState` is recommended and includes additional properties like reading the `pending` state directly. [Learn more](https://react.dev/reference/react/useActionState).
- `useFormStatus` now includes additional keys like `data`, `method`, and `action`. If you are not using React 19, only the `pending` key is available. [Learn more](https://react.dev/reference/react-dom/hooks/useFormStatus).
- Read more in the [React 19 upgrade guide](https://react.dev/blog/2024/04/25/react-19-upgrade-guide).
> **Good to know:** If you are using TypeScript, ensure you also upgrade `@types/react` and `@types/react-dom` to their latest versions.
<AppOnly>
## Async Request APIs (Breaking change)
Previously synchronous Request-time APIs that rely on request information are now **asynchronous**:
......@@ -472,14 +485,10 @@ export async function GET(request, segmentData) {
}
```
<AppOnly>
## `runtime` configuration (Breaking change)
The `runtime` [segment configuration](/docs/app/api-reference/file-conventions/route-segment-config/runtime) previously supported a value of `experimental-edge` in addition to `edge`. Both configurations refer to the same thing, and to simplify the options, we will now error if `experimental-edge` is used. To fix this, update your `runtime` configuration to `edge`. A [codemod](/docs/app/guides/upgrading/codemods#app-dir-runtime-config-experimental-edge) is available to automatically do this.
</AppOnly>
## `fetch` requests
[`fetch` requests](/docs/app/api-reference/functions/fetch) are no longer cached by default.
......@@ -542,6 +551,8 @@ module.exports = nextConfig
[Layouts](/docs/app/api-reference/file-conventions/layout) and [loading states](/docs/app/api-reference/file-conventions/loading) are still cached and reused on navigation.
</AppOnly>
## `next/font`
The `@next/font` package has been removed in favor of the built-in [`next/font`](/docs/app/api-reference/components/font). A [codemod is available](/docs/app/guides/upgrading/codemods#built-in-next-font) to safely and automatically rename your imports.
......@@ -645,10 +656,15 @@ After applying the changes relevant to your app, review these action items befor
you consider the migration complete:
- [ ] React dependencies and types meet the React 19 requirements for the app's router.
- [ ] Async Request API access, including affected helpers and callers, is migrated. Resolve codemod error comments and `UnsafeUnwrapped` casts instead of treating them as completed repairs.
- [ ] Route segment runtime settings no longer use `experimental-edge`.
- [ ] Font imports use `next/font` instead of `@next/font`.
- [ ] Existing `bundlePagesExternals` and `serverComponentsExternalPackages` settings use their documented stable names while preserving package configuration.
- [ ] `NextRequest` `geo` and `ip` consumers use an appropriate source for the actual hosting provider.
- [ ] Apps that relied on automatic Speed Insights instrumentation have an explicit integration if they still need it.
- [ ] The app's supported checks and affected runtime behavior pass. Remaining required failures keep the migration incomplete.
<AppOnly>
- [ ] Async Request API access, including affected helpers and callers, is migrated. Resolve codemod error comments and `UnsafeUnwrapped` casts instead of treating them as completed repairs.
- [ ] Route segment runtime settings no longer use `experimental-edge`.
</AppOnly>
......@@ -254,6 +254,8 @@ export default nextConfig
Turbopack stores compiler artifacts on disk between runs, for significantly faster compile times across restarts. Filesystem caching is enabled by default for both `next dev` and `next build`, through `experimental.turbopackFileSystemCacheForDev` and `experimental.turbopackFileSystemCacheForBuild`. See [Turbopack FileSystem Caching](/docs/app/api-reference/config/next-config-js/turbopackFileSystemCache) to configure or disable either one.
<AppOnly>
## Async Request APIs (Breaking change)
Version 15 introduced [Async Request APIs](https://nextjs.org/docs/app/guides/upgrading/version-15#async-request-apis-breaking-change) as a breaking change, with **temporary** synchronous compatibility.
......@@ -368,6 +370,8 @@ The App Router in **Next.js 16** uses the latest React [Canary release](https://
Learn more in the [React 19.2 announcement](https://react.dev/blog/2025/10/01/react-19-2).
</AppOnly>
## React Compiler Support
Built-in support for the React Compiler is now stable in **Next.js 16** following the React Compiler's 1.0 release. The React Compiler automatically memoizes components, reducing unnecessary re-renders with zero manual code changes.
......@@ -413,6 +417,8 @@ bun add -D babel-plugin-react-compiler
> **Good to know:** Expect compile times in development and during builds to be higher when enabling this option as the React Compiler relies on Babel.
<AppOnly>
## Caching APIs
### revalidateTag
......@@ -585,6 +591,8 @@ const nextConfig = {
module.exports = nextConfig
```
</AppOnly>
## `middleware` to `proxy`
The `middleware` filename is deprecated, and has been renamed to `proxy` to clarify network boundary and routing focus.
......@@ -906,6 +914,8 @@ yarn next internal trace .next-profiles/trace-turbopack.bin
bunx next internal trace .next-profiles/trace-turbopack.bin
```
<AppOnly>
## Parallel Routes `default.js` requirement
All [parallel route](/docs/app/api-reference/file-conventions/parallel-routes) slots now require explicit `default.js` files. Builds will fail without them.
......@@ -928,6 +938,8 @@ export default function Default() {
}
```
</AppOnly>
## ESLint Flat Config
`@next/eslint-plugin-next` now defaults to ESLint Flat Config format, aligning with ESLint v10 which will drop legacy config support.
......@@ -950,6 +962,8 @@ In **Next.js 16**, this behavior has changed. By default, Next.js will **no long
**If you want Next.js to perform this override** (the previous default behavior), add the `data-scroll-behavior="smooth"` attribute to your `<html>` element:
<AppOnly>
```tsx filename="app/layout.tsx"
export default function RootLayout({ children }) {
return (
......@@ -960,6 +974,28 @@ export default function RootLayout({ children }) {
}
```
</AppOnly>
<PagesOnly>
```tsx filename="pages/_document.tsx"
import { Html, Head, Main, NextScript } from 'next/document'
export default function Document() {
return (
<Html lang="en" data-scroll-behavior="smooth">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
```
</PagesOnly>
## Performance Improvements
Significant performance optimizations for `next dev` and `next start` commands, along with improved terminal output with clearer formatting, better error messages, and improved performance metrics.
......@@ -1175,6 +1211,8 @@ The following options have been removed from [`devIndicators`](/docs/app/api-ref
The indicator itself remains available.
<AppOnly>
### `experimental.dynamicIO` and `experimental.useCache`
The `experimental.dynamicIO` and `experimental.useCache` flags have been removed.
......@@ -1225,6 +1263,8 @@ For the full migration path, see [Migrating to Cache Components](/docs/app/guide
The `unstable_rootParams` function has been removed. Use [`next/root-params`](/docs/app/api-reference/functions/next-root-params) instead.
</AppOnly>
## Troubleshooting
### Installation fails after upgrading to React 19
......@@ -1244,13 +1284,18 @@ After applying the changes relevant to your app, review these action items befor
you consider the migration complete:
- [ ] The app meets the Node.js, TypeScript, and React requirements in this guide.
- [ ] Async Request API access and affected callers are migrated. Resolve codemod error comments and `UnsafeUnwrapped` casts; use React `use` for synchronous Client Components where appropriate.
- [ ] Dynamic metadata image functions and sitemap functions handle their asynchronous parameters, and affected generated URLs work.
- [ ] Development and build scripts agree with the effective bundler configuration, including plugins, loaders, aliases, and affected Sass imports.
- [ ] Middleware and proxy changes preserve the required runtime and routing behavior. Edge middleware is not blindly renamed to proxy.
- [ ] Parallel route slots have appropriate defaults, and direct navigation and reloads retain the intended fallback behavior.
- [ ] Affected image requests succeed under the documented restrictions and defaults while preserving the intended quality.
- [ ] Existing cache API calls follow the documented signatures and semantics. React Compiler and Cache Components are not enabled merely to complete the upgrade.
- [ ] Removed APIs and configuration have no remaining consumers. Runtime configuration replacements preserve server and client visibility and the required evaluation time.
- [ ] Scripts and CI no longer invoke `next lint`; linting runs separately where the app requires it.
- [ ] The app's supported checks and affected runtime behavior pass. A green build alone does not close runtime findings.
<AppOnly>
- [ ] Async Request API access and affected callers are migrated. Resolve codemod error comments and `UnsafeUnwrapped` casts; use React `use` for synchronous Client Components where appropriate.
- [ ] Dynamic metadata image functions and sitemap functions handle their asynchronous parameters, and affected generated URLs work.
- [ ] Parallel route slots have appropriate defaults, and direct navigation and reloads retain the intended fallback behavior.
</AppOnly>
---
title: How to upgrade to version 15
nav_title: Version 15
description: Upgrade your Next.js Application from Version 14 to 15.
source: app/guides/upgrading/version-15
---
{/* DO NOT EDIT. The content of this doc is generated from the source above. To edit the content of this page, navigate to the source page in your editor. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
---
title: How to upgrade to version 16
nav_title: Version 16
description: Upgrade your Next.js Application from Version 15 to 16.
source: app/guides/upgrading/version-16
---
{/* DO NOT EDIT. The content of this doc is generated from the source above. To edit the content of this page, navigate to the source page in your editor. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment