Next.js 升级:自动化框架迁移 - Openclaw Skills
作者:互联网
2026-04-05
什么是 Next.js 升级助手?
此技能通过提供结构化、自动化的框架维护方法,简化了升级 Next.js 应用程序这一通常很复杂的过程。通过利用 Openclaw Skills,开发人员可以自动检测其当前的项目环境,实时获取最新的官方迁移文档,并确定版本转换的最安全路径。
该技能侧重于通过智能应用官方 codemods 并确保 React 和 React DOM 等对等依赖项完全同步,来减少重大变更(breaking changes)带来的摩擦。无论您是从版本 13 迁移到 15,还是紧跟最新的实验性版本,此工具都能确保您的代码库遵循 Vercel 团队建立的官方最佳实践。
下载入口:https://github.com/openclaw/skills/tree/main/skills/tuanvidev/next-upgrade
安装与下载
1. ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install next-upgrade
2. 手动安装
将技能文件夹复制到以下位置之一
全局模式~/.openclaw/skills/
工作区
/skills/
优先级:工作区 > 本地 > 内置
3. 提示词安装
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 next-upgrade。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
Next.js 升级助手 应用场景
- 将旧的 Next.js 13 或 14 项目迁移到最新的稳定版本。
- 在大型代码库中自动应用官方 Next.js codemods 以应对重大的 API 变更。
- 确保在框架跨版本升级期间,对等依赖项和 TypeScript 类型正确同步。
- 自动识别并修复 next.config.js 中已弃用的配置选项。
- 扫描本地 package.json 以识别当前的 Next.js、React 和 React DOM 版本。
- 使用 WebFetch 从 nextjs.org 获取最新的特定版本的迁移指南和 codemod 文档。
- 确定是否需要增量升级路径(例如,在升级到 v15 之前先升级到 v14)以保持稳定性。
- 通过 npx 执行相关的 codemods,以转换异步请求 API、地理位置/IP 属性和动态导入。
- 使用项目的包管理器更新核心依赖项和 TypeScript 类型定义。
- 对配置进行手动检查并运行构建检查以验证迁移是否成功。
Next.js 升级助手 配置指南
要在您的开发环境中使用此技能,请确保已安装 Openclaw Skills 框架。您可以通过运行以下命令启动升级序列:
# 运行 Next.js 升级工作流
openclaw run next-upgrade
该技能需要标准的 Node.js 环境,如果参数中未指定目标版本,则会提示输入。
Next.js 升级助手 数据架构与分类体系
该技能与项目元数据和远程文档的交互如下:
| 来源 | 数据类型 | 用途 |
|---|---|---|
| package.json | 文件 | 读取当前版本并写入更新后的依赖项。 |
| next.config.js | 文件 | 审核已弃用的功能或更改的 API 接口。 |
| 官方文档 | URL | 获取版本 14、15 和 16 的实时迁移指令。 |
| Codemods | CLI | 在源目录上执行 @next/codemod 转换。 |
name: next-upgrade
description: Upgrade Next.js to the latest version following official migration guides and codemods
argument-hint: "[target-version]"
Upgrade Next.js
Upgrade the current project to the latest Next.js version following official migration guides.
Instructions
-
Detect current version: Read
package.jsonto identify the current Next.js version and related dependencies (React, React DOM, etc.) -
Fetch the latest upgrade guide: Use WebFetch to get the official upgrade documentation:
- Codemods: https://nextjs.org/docs/app/guides/upgrading/codemods
- Version-specific guides (adjust version as needed):
- https://nextjs.org/docs/app/guides/upgrading/version-16
- https://nextjs.org/docs/app/guides/upgrading/version-15
- https://nextjs.org/docs/app/guides/upgrading/version-14
-
Determine upgrade path: Based on current version, identify which migration steps apply. For major version jumps, upgrade incrementally (e.g., 13 → 14 → 15).
-
Run codemods first: Next.js provides codemods to automate breaking changes:
npx @next/codemod@latestCommon 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)
-
Update dependencies: Upgrade Next.js and peer dependencies together:
npm install next@latest react@latest react-dom@latest -
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
-
Update TypeScript types (if applicable):
npm install @types/react@latest @types/react-dom@latest -
Test the upgrade:
- Run
npm run buildto check for build errors - Run
npm run devand test key functionality
- Run
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
HealthClaw 牙科:AI 驱动的牙科诊所管理 - Openclaw Skills
ERPClaw 销售:AI 订单到现金全生命周期管理 - Openclaw Skills
ERPClaw 欧盟区域合规:增值税、OSS 和电子发票 - Openclaw Skills
ERPClaw 人事:AI 人力资源与美国薪酬管理 - Openclaw Skills
erpclaw-journals:安全且AI原生的簿记系统 - Openclaw Skills
ERPClaw Growth:AI CRM 与业务分析 - Openclaw Skills
ERPClaw Billing:基于用量与计量的计费 - Openclaw Skills
educlaw: AI 原生教育与 SIS 管理 - Openclaw Skills
EduClaw K-12 扩展组件:学生管理与合规 - Openclaw Skills
AuditClaw AWS:自动化 AWS 合规证据收集 - Openclaw Skills
AI精选
