How to Update Next.js
Option 1: Automatic Upgrade Command
The easiest way to update Next.js is to use the official upgrade command:
npx @next/codemod upgrade latestThis command automatically:
- Updates next.config.js with new turbopack configuration
- Migrates from next lint to the ESLint CLI
- Migrates deprecated middleware to the new proxy-based middleware system
- Removes unstable_ prefix from stabilized APIs
- Removes experimental_ppr Route Segment Config
Option 2: Manual Package Update
If you prefer manual control, install the latest versions directly using your package manager:
Using npm:
npm i next@latest react@latest react-dom@latest eslint-config-next@latestUsing pnpm:
pnpm i next@latest react@latest react-dom@latest eslint-config-next@latestUsing Yarn:
yarn add next@latest react@latest react-dom@latest eslint-config-next@latestUsing Bun:
bun add next@latest react@latest react-dom@latest eslint-config-next@latestImportant for TypeScript users: Ensure you also upgrade @types/react and @types/react-dom to their latest versions.
Updating to Specific Patched Versions
To update to a specific patched version based on your current Next.js release line:
npm install next@15.0.5 # for 15.0.x usersnpm install next@15.1.9 # for 15.1.x usersnpm install next@15.2.6 # for 15.2.x usersnpm install next@15.3.6 # for 15.3.x usersnpm install next@15.4.8 # for 15.4.x usersnpm install next@15.5.7 # for 15.5.x usersnpm install next@16.0.7 # for 16.0.x usersFor React Router Users
If you’re using React Router’s unstable RSC APIs, upgrade the following dependencies:
npm install react@latestnpm install react-dom@latestnpm install react-server-dom-parcel@latestnpm install react-server-dom-webpack@latestnpm install @vitejs/plugin-rsc@latestVerifying Your Update
After updating, verify your installation by checking the versions:
npm list next react react-domEnsure all packages are updated to the patched versions listed above.
Additional safety measures
Once the package is upgraded, make sure to perform cleanup in your VPS server. Detailed steps can be found What to Do if Your VPS Has Been Hacked at Hostinger?