Upgrade and migration workflow
What you need to know
An upgrade is a controlled change to framework, runtime and dependency contracts. Next.js codemods can automate source edits, but a migration is complete only after behavior and security checks pass.
By the end, you can: review codemod diff; plan security and compatibility retests.
Migrate an asynchronous route prop
export default async function Page({params}:{params:Promise<{slug:string}>}) { const {slug} = await params; return <h1>{slug}</h1>;}Expected behavior: In the modern App Router page convention, await params before reading slug. The example is staged, not framework-tested.
How it works
Inventory exact installed Next.js, React, React DOM, Node, TypeScript, plugins, lockfile and deployment adapters. Review official support policy, advisories and every applicable migration guide before selecting a patched target. Work on a reviewed branch; record baseline build, routes, auth, cache and accessibility tests. Codemods are executable dependencies: select a reviewed version, run only in a disposable copy and review every diff. The documented next upgrade CLI was introduced in 16.1; earlier installations need the separate upgrade tool described in their guide. Check the installed CLI before selecting a command. In the 16.x migration lane, modern request APIs such as cookies, headers and draftMode are async, and route props use Promise forms where applicable. Proxy replaces middleware naming for the modern Node-based convention, but runtime changes may require redesign, not a mechanical rename. Verify Turbopack versus Webpack config and cache defaults independently. Cache Components is a separate migration decision; do not silently enable it as part of a version bump. Rebuild and run production-mode route tests, compare metadata and cache behavior, and test previous artifact rollback with the current schema. A supported major version does not prove a specific patch is secure. This batch has not selected exact dependency patches.
Migration acceptance record
{ "source": "previous reviewed artifact", "target": "candidate reviewed patch", "gates": { "routeContract": "pending", "authorization": "pending", "cache": "pending", "rollback": "pending", "advisories": "pending" }, "promotion": "blocked"}Expected behavior: An unrun critical gate prevents release, even if a codemod finished.
Common mistake
Do not run an unpinned upgrade script on a trusted production checkout or suppress errors to get a green build. A codemod cannot infer business policy.
Practice and verification
Prepare a migration worksheet for a Pages/App coexistence project. List the async API changes, proxy runtime, bundler config, cache lane, test ownership and rollback conditions. Mark checks not run without the exact toolchain.
Scope: Proposed Next.js 16.x / React 19; App Router, Cache Components disabled unless noted. Framework and browser examples are staged, not executed. No exact patched dependency release or live deployment verified.