๐ก๐ฒ๐ ๐.๐ท๐ ๐ฃ๐ฎ๐ด๐ฒ๐ ๐ฅ๐ผ๐๐๐ฒ๐ฟ ๐๐ผ ๐๐ฝ๐ฝ ๐ฅ๐ผ๐๐๐ฒ๐ฟ ๐ ๐ถ๐ด๐ฟ๐ฎ๐๐ถ๐ผ๐ป ๐๐๐ถ๐ฑ๐ฒ ๐ฎ๐ฌ๐ฎ๐ฒ
Move from Pages Router to App Router one route at a time. Both routers run in the same project. This makes the change easy.
Here are the main changes:
- File paths: pages/index.tsx becomes app/page.tsx.
- Layouts: _app.tsx becomes layout.tsx.
- Data: getServerSideProps becomes Async Server Components.
- Components: Server by default. Use 'use client' for client components.
- Metadata: Use metadata export instead of next/head.
- API: Move to app/api/route/route.ts.
- States: Use loading.tsx and error.tsx.
- Streaming: Now built-in with Suspense.
How to migrate:
- Run npm install next@latest react@latest react-dom@latest.
- Create an app directory.
- Build a root layout.tsx.
- Move routes one by one. Routes in the app folder take priority.
Important tips:
- Use next/navigation instead of next/router.
- Use generateStaticParams instead of getStaticPaths.
Should you migrate?
- Active projects: Yes. It improves performance.
- Stable projects: No. The effort is too high.
- New projects: Always start with App Router.
Source: https://dev.to/thekitbase/nextjs-pages-router-to-app-router-migration-guide-2026-4iep