diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-01-16 08:30:14 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-01-16 08:30:14 +0900 |
| commit | 3fbb9a18372f2b6a675dd6c039ba52be76f3eeb4 (patch) | |
| tree | aa694a36cdd323a7853672ee7a2ba60409ac3b06 /frameworks/nextjs-15/.claude/commands/migrate-to-app-router.md | |
updates
Diffstat (limited to 'frameworks/nextjs-15/.claude/commands/migrate-to-app-router.md')
| -rw-r--r-- | frameworks/nextjs-15/.claude/commands/migrate-to-app-router.md | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/frameworks/nextjs-15/.claude/commands/migrate-to-app-router.md b/frameworks/nextjs-15/.claude/commands/migrate-to-app-router.md new file mode 100644 index 0000000..8801147 --- /dev/null +++ b/frameworks/nextjs-15/.claude/commands/migrate-to-app-router.md @@ -0,0 +1,48 @@ +--- +allowed-tools: Read, Write, MultiEdit, Glob, Grep, TodoWrite +argument-hint: "[page-path|all]" +description: Migrate Pages Router components to App Router +--- + +Migrate Pages Router to App Router for: $ARGUMENTS + +## Migration Steps + +1. **Analyze Current Structure** + - Identify pages to migrate + - Check for getServerSideProps, getStaticProps, getStaticPaths + - Find _app.tsx and_document.tsx customizations + +2. **Create App Router Structure** + - Create corresponding app/ directory structure + - Convert pages to page.tsx files + - Extract layouts from _app.tsx + +3. **Migrate Data Fetching** + - getStaticProps → Direct fetch in Server Component + - getServerSideProps → Direct fetch in Server Component + - getStaticPaths → generateStaticParams + - API calls in useEffect → Keep in Client Component or move to Server + +4. **Update Routing Hooks** + - useRouter from next/router → next/navigation + - Update router.push() calls + - Handle query params with useSearchParams + +5. **Migrate Metadata** + - Head component → metadata export or generateMetadata + - Update SEO configuration + +6. **Handle Special Files** + - _app.tsx → app/layout.tsx + - _document.tsx → app/layout.tsx (html/body tags) + - _error.tsx → app/error.tsx + - 404.tsx → app/not-found.tsx + +7. **Test and Validate** + - Ensure all routes work + - Verify data fetching + - Check that layouts render correctly + - Test client-side navigation + +Create a migration log documenting all changes and any issues that need manual review. |
