Next Upgrade

作者 vercel882e66c26986无许可证收录于 2026年10月8日更新于 2026年10月8日

Upgrade Next.js to the latest version following official migration guides and codemods. Use when upgrading Next.js versions, running codemods, or migrating between major releases.

AI 生成的概览

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

功能
逐步完成 Next.js 版本升级:从 package.json 检测当前版本、获取官方升级指南、规划增量迁移路径、运行 Next.js codemod、更新 Next.js 及同级依赖,并检查破坏性变更。还涵盖更新 TypeScript 类型以及通过构建和开发运行验证结果。产出是升级后的项目以及关于手动修改的指导。
适用场景
适用于将 Next.js 项目升级到较新或最新版本、运行 Next.js codemod,或在主要版本之间迁移(例如 13 到 14 到 15)。也适用于在此类升级中处理破坏性变更或配置更新。
运行要求
需要已有的 Next.js 项目(含 package.json)和 Node.js 工具链(npm、pnpm、yarn 或 bun)。需要网络访问以获取官方升级文档并安装依赖包和 codemod。该技能不附带脚本,仅为操作说明。

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/vercel-plugin位于skills/next-upgrade提交882e66c

许可证: 无许可证

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

举报或申请下架