Next Upgrade

作者 vercel-labs672deb21e70e无许可证1.6K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7个月前更新

Upgrade Next.js to the latest version following official migration guides and codemods

精选仅含说明Software Development
AI 生成的概览

依据官方迁移指南和 codemod,指导将 Next.js 项目升级到最新版本。

功能
引导智能体升级 Next.js 项目:从 package.json 识别当前版本、获取官方升级指南、确定逐步升级路径、运行 Next.js codemod、更新 Next.js 及同级依赖、检查破坏性变更、更新 TypeScript 类型并测试构建。产出升级后的项目以及一系列迁移步骤和命令。
适用场景
当 Next.js 应用需要升级到更新的主版本或次版本,并希望遵循官方指南和 codemod 进行迁移时使用。也适合规划逐步版本跃迁并在升级前检查破坏性变更。
运行要求
需要网络访问以获取 Next.js 升级文档,需要具备 npm 和 npx 的 Node.js 项目,以及项目的 package.json。该技能不附带脚本,仅为说明性指令。

Upgrade Next.js

Upgrade the current project to the latest Next.js version following official migration guides.

Instructions

  1. Detect current version: Read package.json to identify the current Next.js version and related dependencies (React, React DOM, etc.)

  2. Fetch the latest upgrade guide: Use WebFetch to get the official upgrade documentation:

  3. Determine upgrade path: Based on current version, identify which migration steps apply. For major version jumps, upgrade incrementally (e.g., 13 → 14 → 15).

  4. Run codemods first: Next.js provides codemods to automate breaking changes:

    bash
    npx @next/codemod@latest <transform> <path>

    Common transforms:

    • next-async-request-api - Updates async Request APIs (v15)
    • next-request-geo-ip - Migrates geo/ip properties (v15)
    • next-dynamic-access-named-export - Transforms dynamic imports (v15)
  5. Update dependencies: Upgrade Next.js and peer dependencies together:

    bash
    npm install next@latest react@latest react-dom@latest
  6. Review breaking changes: Check the upgrade guide for manual changes needed:

    • API changes (e.g., async params in v15)
    • Configuration changes in next.config.js
    • Deprecated features being removed
  7. Update TypeScript types (if applicable):

    bash
    npm install @types/react@latest @types/react-dom@latest
  8. Test the upgrade:

    • Run npm run build to check for build errors
    • Run npm run dev and test key functionality

来源与署名

来源:vercel-labs/openreview位于.agents/skills/next-upgrade提交672deb2

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架