next upgrade, Codemods, Dependencies & Compatibility
Modern Next.js provides first-party upgrade tooling, but automation changes syntax better than it proves system behavior.
The practical model is:
tool-assisted transformation
+
manual semantic review
+
production validation
1. next upgradeβ
From Next.js 16.1+, the next CLI includes an upgrade command:
pnpm next upgrade
Useful variants include targeting a specific revision or release channel.
Use stable latest or an exact supported version for normal production upgrades.
2. Older versions use the codemod packageβ
Projects on versions before the built-in upgrade command can use:
npx @next/codemod@canary upgrade latest
The upgrade flow can update framework packages and offer relevant transforms.
Always commit or branch before running automated transforms.
3. Run codemods on a clean working treeβ
Recommended flow:
clean branch
β lock baseline tests/build
β run codemod
β inspect diff
β commit codemod-only changes
β fix semantic issues separately
Do not mix large manual refactors into the same commit as generated changes.
4. Useful codemod controlsβ
Codemods support options such as dry-run and printed output.
Use them when the transform touches sensitive code or a large monorepo.
A good workflow is:
dry run
β inspect representative changes
β run transform
β review every category of change
5. Important modern transformsβ
Current Next.js upgrade tooling includes migrations for concerns such as:
async request APIs
middleware β proxy
next lint β direct ESLint CLI
old experimental PPR config removal
unstable_ prefixes of stabilized APIs
Turbopack config updates
Each transform addresses a specific framework change. Do not assume one codemod handles every architectural migration.
6. Async request API codemodβ
The async API migration can rewrite calls such as:
cookies()
headers()
draftMode()
and framework props such as params / searchParams where possible.
The transform may use await in server contexts or React use() where a synchronous component shape must consume a Promise.
Manual review is still required around:
function signatures
shared helpers
client/server boundaries
tests
third-party wrappers
7. Middleware to Proxy codemodβ
The migration changes the convention from middleware.ts to proxy.ts and associated naming.
Do not interpret the rename as permission to keep adding application logic at the request front door.
After the transform, review:
matchers
redirects/rewrites
header mutation
cookies
auth gating
prefetch exclusions
runtime assumptions
8. Lint migrationβ
Next.js 16 removes next lint and no longer runs linting as part of next build.
Your CI must therefore invoke the chosen lint tool explicitly.
Example shape:
{
"scripts": {
"lint": "eslint .",
"build": "next build"
}
}
Do not accidentally lose lint enforcement while upgrading.
9. Package updates are a dependency graph migrationβ
The framework package is only one node.
Review:
next
react
react-dom
@types/react
@types/react-dom
eslint-config-next
typescript
node runtime
test environment
build plugins
observability SDKs
auth libraries
For monorepos, include shared packages that compile against Next/React types.
10. Keep React versions compatible with Next.jsβ
App Router uses framework-managed React integration.
Do not independently pin arbitrary React canary builds into production unless the framework documentation supports that combination.
When upgrading a major Next version, read its React requirements and upgrade React types together.
11. Type generation is useful migration evidenceβ
Modern Next.js can generate route-aware type helpers through:
npx next typegen
Generated helpers can improve migrations around:
PageProps
LayoutProps
RouteContext
This is especially valuable after async params / searchParams changes.
12. Lockfiles are part of reproducibilityβ
A migration commit should update the lockfile intentionally.
Review unexpected dependency churn.
Questions:
Did a transitive native package change?
Did multiple React copies appear?
Did a test library jump major versions?
Did an optional package become production-required?
13. Peer dependency warnings are signalsβ
Do not suppress peer dependency warnings blindly.
Classify each as:
safe stale declaration
actual incompatibility
unsupported package
duplicate React risk
tooling-only mismatch
Prefer upgrading or replacing packages whose compatibility is genuinely broken.
14. Native packages need runtime verificationβ
Dependencies involving native binaries or platform-specific behavior deserve extra checks:
image processing
database drivers
OpenTelemetry exporters
password hashing
canvas/media tooling
A build on one environment does not prove runtime compatibility on another architecture/libc/container base.
15. Bundler compatibility mattersβ
Turbopack is the default for current Next.js dev and build.
If the old app depends on Webpack-specific configuration, classify each customization:
still necessary
has Turbopack equivalent
package can be changed
must temporarily use --webpack
blocks upgrade
Do not keep Webpack forever because one historical loader was never re-evaluated.
16. Test framework upgrades separately when possibleβ
A framework migration plus a JestβVitest migration plus a Playwright major upgrade produces too many simultaneous variables.
Prefer:
framework upgrade first
β preserve confidence system
β modernize testing separately
unless the old tooling is itself incompatible.
17. Build plugins and wrappers need explicit reviewβ
Packages that wrap next.config can alter build behavior:
bundle analyzers
Sentry/observability integrations
MDX/CMS plugins
PWA plugins
CSS-in-JS transforms
internationalization wrappers
Validate the final composed config, not each plugin in isolation.
18. Remove obsolete workaroundsβ
Framework upgrades often make old hacks unnecessary.
Search for comments and config such as:
TEMP Next 14 workaround
Webpack-only alias
legacy hydration fix
manual polyfill
experimental flag
Every workaround should have an owner and reason to survive the upgrade.
19. Codemod review checklistβ
After automation, inspect:
imports
async boundaries
function signatures
runtime directives
route config
cache behavior
Proxy matchers
lint scripts
removed config
client bundle boundaries
Generated code is not automatically correct code.
20. CI matrix during a major upgradeβ
For high-risk systems, temporarily test:
current production branch
migration branch
representative Node/runtime target
production build
critical browser flows
This makes before/after regressions visible before traffic moves.
21. Commit structureβ
A reviewable migration often looks like:
commit 1: upgrade packages + lockfile
commit 2: official codemods
commit 3: manual API fixes
commit 4: cache/runtime behavior migration
commit 5: remove compatibility workarounds
commit 6: production regression fixes
Exact structure varies, but separation improves debugging.
Senior ruleβ
Use automation to reduce mechanical work.
Never delegate semantic ownership of:
security
caching
rendering
runtime compatibility
production rollout
to a codemod.