packages/next/src/migrations/update-23-1-0/ai-instructions-for-next-15.md
Migrate the Nx workspace's Next.js projects from 14 to 15. Run the codemod first, fix the rest by hand, build after each project.
npx @next/codemod@canary upgrade 15
Pin to 15 (not latest - that now resolves to 16). The @canary tag is what Next ships the upgrade codemod on. Handles most async-API rewrites. Review the diff.
Next 15 App Router requires React 19. Page Router can stay on React 18. For App Router projects, also run the React 18 -> 19 migration.
cookies, headers, draftMode, params, searchParams are now async. Codemod covers most; fix leftovers.
// before
const { slug } = params;
// after
const { slug } = await props.params;
Make the component / handler async and await the value.
App Router only - Pages Router getServerSideProps / getStaticProps / getStaticPaths context.params is NOT async; leave it unchanged.
No longer cached by default: fetch, GET route handlers, client navigations. Re-add caching where you relied on it.
fetch(url, { cache: 'force-cache' })export const dynamic = 'force-static'@next/font removed -> import from next/font.runtime: 'experimental-edge' -> runtime: 'edge'.next.config renames: experimental.bundlePagesExternals -> top-level bundlePagesRouterDependencies; experimental.serverComponentsExternalPackages -> top-level serverExternalPackages.NextRequest.geo / request.ip removed (e.g. in middleware) -> read from headers (x-forwarded-for, platform geo headers).nx run PROJECT:build
nx affected -t build,lint,test