$npx -y skills add vercel-labs/openreview --skill next-upgradenext-upgrade is an agent skill published from vercel-labs/openreview, installable through the skills CLI.
| 1 | # Upgrade Next.js |
| 2 | |
| 3 | Upgrade the current project to the latest Next.js version following official migration guides. |
| 4 | |
| 5 | ## Instructions |
| 6 | |
| 7 | 1. **Detect current version**: Read `package.json` to identify the current Next.js version and related dependencies (React, React DOM, etc.) |
| 8 | |
| 9 | 2. **Fetch the latest upgrade guide**: Use WebFetch to get the official upgrade documentation: |
| 10 | - Codemods: https://nextjs.org/docs/app/guides/upgrading/codemods |
| 11 | - Version-specific guides (adjust version as needed): |
| 12 | - https://nextjs.org/docs/app/guides/upgrading/version-16 |
| 13 | - https://nextjs.org/docs/app/guides/upgrading/version-15 |
| 14 | - https://nextjs.org/docs/app/guides/upgrading/version-14 |
| 15 | |
| 16 | 3. **Determine upgrade path**: Based on current version, identify which migration steps apply. For major version jumps, upgrade incrementally (e.g., 13 → 14 → 15). |
| 17 | |
| 18 | 4. **Run codemods first**: Next.js provides codemods to automate breaking changes: |
| 19 | ```bash |
| 20 | npx @next/codemod@latest <transform> <path> |
| 21 | ``` |
| 22 | Common transforms: |
| 23 | - `next-async-request-api` - Updates async Request APIs (v15) |
| 24 | - `next-request-geo-ip` - Migrates geo/ip properties (v15) |
| 25 | - `next-dynamic-access-named-export` - Transforms dynamic imports (v15) |
| 26 | |
| 27 | 5. **Update dependencies**: Upgrade Next.js and peer dependencies together: |
| 28 | ```bash |
| 29 | npm install next@latest react@latest react-dom@latest |
| 30 | ``` |
| 31 | |
| 32 | 6. **Review breaking changes**: Check the upgrade guide for manual changes needed: |
| 33 | - API changes (e.g., async params in v15) |
| 34 | - Configuration changes in `next.config.js` |
| 35 | - Deprecated features being removed |
| 36 | |
| 37 | 7. **Update TypeScript types** (if applicable): |
| 38 | ```bash |
| 39 | npm install @types/react@latest @types/react-dom@latest |
| 40 | ``` |
| 41 | |
| 42 | 8. **Test the upgrade**: |
| 43 | - Run `npm run build` to check for build errors |
| 44 | - Run `npm run dev` and test key functionality |