mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
89d017eac4
## Summary - warn during `next dev` and `next build` when React 18 is installed, while keeping `next start` quiet - explain that React 18 remains supported in Next.js 16 but will be removed in Next.js 17 - update the React version guidance with React 19 and TypeScript type upgrade commands ## Verification - `NEXT_TEST_PREFER_OFFLINE=1 pnpm test-dev-turbo test/e2e/react-current-version/react-current-version.test.ts` - `NEXT_TEST_REACT_VERSION=18.3.1 NEXT_TEST_PREFER_OFFLINE=1 pnpm test-dev-turbo test/e2e/react-current-version/react-current-version.test.ts` - targeted production build/start coverage passed with React 18 and React 19 - Not passing: `pnpm --filter=next types` (existing unrelated errors in `httpget.ts`, `image-optimizer.ts`, `proxy-request.ts`, telemetry typings, and compiled declarations) - Not passing: `pnpm lint` (existing unused Turbo Tasks check) <!-- NEXT_JS_LLM -->
62 lines
1.7 KiB
Plaintext
62 lines
1.7 KiB
Plaintext
---
|
|
title: React Version Support
|
|
description: Learn which React versions are supported by Next.js and how to upgrade.
|
|
---
|
|
|
|
## Why This Error Occurred
|
|
|
|
Your project is using a version of `react` or `react-dom` that is unsupported or
|
|
deprecated in your version of Next.js.
|
|
|
|
- React versions earlier than `18.2.0` are unsupported.
|
|
- React 18.2 and later remain supported in Next.js 16, but React 18 support is
|
|
deprecated.
|
|
- React 19 is recommended for Next.js 16 and will be required in Next.js 17.
|
|
|
|
React 19 includes features used by Next.js, such as Actions and improved
|
|
hydration errors. Upgrade `react` and `react-dom` together to keep their versions
|
|
in sync.
|
|
|
|
If you use TypeScript, upgrade `@types/react` and `@types/react-dom` at the same
|
|
time.
|
|
|
|
## Possible Ways to Fix It
|
|
|
|
Upgrade React and its TypeScript types with your package manager:
|
|
|
|
```bash package="npm"
|
|
npm install react@latest react-dom@latest @types/react@latest @types/react-dom@latest
|
|
```
|
|
|
|
```bash package="yarn"
|
|
yarn add react@latest react-dom@latest @types/react@latest @types/react-dom@latest
|
|
```
|
|
|
|
```bash package="pnpm"
|
|
pnpm add react@latest react-dom@latest @types/react@latest @types/react-dom@latest
|
|
```
|
|
|
|
```bash package="bun"
|
|
bun add react@latest react-dom@latest @types/react@latest @types/react-dom@latest
|
|
```
|
|
|
|
Alternatively, update your `package.json` manually:
|
|
|
|
```json filename="package.json"
|
|
{
|
|
"dependencies": {
|
|
"react": "^19.0.0",
|
|
"react-dom": "^19.0.0"
|
|
},
|
|
"devDependencies": {
|
|
"@types/react": "^19.0.0",
|
|
"@types/react-dom": "^19.0.0"
|
|
}
|
|
}
|
|
```
|
|
|
|
## Useful Links
|
|
|
|
- [React 19 upgrade guide](https://react.dev/blog/2024/04/25/react-19-upgrade-guide)
|
|
- [Upgrading Next.js](/docs/app/getting-started/upgrading)
|