Skip to content

Commit 4269026

Browse files
authored
docs: codemode upgrade command (#87006)
1 parent 5099903 commit 4269026

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

docs/01-app/02-guides/upgrading/codemods.mdx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,43 @@ Replacing `<transform>` and `<path>` with appropriate values.
2222
- `--dry` Do a dry-run, no code will be edited
2323
- `--print` Prints the changed output for comparison
2424

25+
## Upgrade
26+
27+
Upgrades your Next.js application, automatically running codemods and updating Next.js, React, and React DOM.
28+
29+
```bash filename="Terminal"
30+
npx @next/codemod upgrade [revision]
31+
```
32+
33+
### Options
34+
35+
- `revision` (optional): Specify the upgrade type (`patch`, `minor`, `major`), an NPM dist tag (e.g. `latest`, `canary`, `rc`), or an exact version (e.g. `15.0.0`). Defaults to `minor` for stable versions.
36+
- `--verbose`: Show more detailed output during the upgrade process.
37+
38+
For example:
39+
40+
```bash filename="Terminal"
41+
# Upgrade to the latest patch (e.g. 16.0.7 -> 16.0.8)
42+
npx @next/codemod upgrade patch
43+
44+
# Upgrade to the latest minor (e.g. 15.3.7 -> 15.4.8). This is the default.
45+
npx @next/codemod upgrade minor
46+
47+
# Upgrade to the latest major (e.g. 15.5.7 -> 16.0.7)
48+
npx @next/codemod upgrade major
49+
50+
# Upgrade to a specific version
51+
npx @next/codemod upgrade 16
52+
53+
# Upgrade to the canary release
54+
npx @next/codemod upgrade canary
55+
```
56+
57+
> **Good to know**:
58+
>
59+
> - If the target version is the same as or lower than your current version, the command exits without making changes.
60+
> - During the upgrade, you may be prompted to choose which Next.js codemods to apply and run React 19 codemods if upgrading React.
61+
2562
## Codemods
2663

2764
### 16.0

docs/01-app/03-api-reference/06-cli/next.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ To ensure `next-env.d.ts` is present before type-checking run `next typegen`. Th
187187

188188
> **Good to know**: `next typegen` loads your Next.js config (`next.config.js`, `next.config.mjs`, or `next.config.ts`) using the production build phase. Ensure any required environment variables and dependencies are available so the config can load correctly.
189189
190-
## `next upgrade` options
190+
### `next upgrade` options
191191

192192
`next upgrade` upgrades your Next.js application to the latest version.
193193

0 commit comments

Comments
 (0)