tanstack/router/migrate-from-nextjs
Claude Code and agent skill by tanstack/router
- community
Checking that the SKILL.md file is still in the repository.
Step-by-step migration from Next.js App Router to TanStack Start: route definition conversion, API mapping, server function conversion from Server Actions, middleware conversion, data fetching pattern changes.
Install
npx vskill@latest install tanstack/router/migrate-from-nextjsSKILL.md
Migrate from Next.js App Router to TanStack Start
This is a step-by-step migration checklist. Complete tasks in order.
CRITICAL: TanStack Start is isomorphic by default. ALL code runs in both environments unless you usecreateServerFn. This is the opposite of Next.js Server Components, where code is server-only by default.
CRITICAL: TanStack Start usescreateServerFn, NOT"use server"directives. Do not carry over any"use server"or"use client"directives.
CRITICAL: Types are FULLY INFERRED in TanStack Router/Start. Never cast, never annotate inferred values.
Pre-Migration
- [ ] Create a migration branch
- [ ] Install TanStack Start
- [ ] Remove Next.js
Concept Mapping
| Next.js App Router | TanStack Start | |
|---|---|---|
app/page.tsx | src/routes/index.tsx | |
app/layout.tsx | src/routes/__root.tsx | |
app/posts/[id]/page.tsx | src/routes/posts/$postId.tsx | |
app/api/users/route.ts | src/routes/api/users.ts (server property) | |
"use server" + Server Actions | createServerFn() | |
"use client" | Not needed (everything is isomorphic) | |
| Server Components (default) | All components are isomorphic; use createServerFn for server-only logic | |
next/navigation useRouter | useRouter() from @tanstack/react-router | |
next/link Link | <Link> from @tanstack/react-router | |
next/head or metadata export | head property on route | |
middleware.ts (edge) | createMiddleware() in src/start.ts | |
next.config.js | vite.config.ts with tanstackStart() | |
generateStaticParams | prerender config in vite.config.ts |
Step 1: Vite Configuration
Replace next.config.js with:
Update package.json:
Step 2: Router Factory
Step 3: Convert Layout → Root Route
Next.js:
TanStack Start:
Step 4: Convert Pages → File Routes
Next.js:
TanStack Start:
Key differences:
- Dynamic segments use
$paramnot[param] - Params accessed via
Route.useParams()not component props - Route path in filename uses
.or/separators
Step 5: Convert Server Actions → Server Functions
Next.js:
TanStack Start:
Step 6: Convert Data Fetching
Next.js Server Component:
TanStack Start:
Step 7: Convert API Routes → Server Routes
Next.js:
TanStack Start:
Step 8: Convert Navigation
Next.js:
TanStack Start:
Never interpolate params into the to string. Use params prop.
Step 9: Convert Middleware
Next.js:
TanStack Start:
Step 10: Convert Metadata/SEO
Next.js:
TanStack Start:
Post-Migration Checklist
- [ ] Remove all
"use server"and"use client"directives - [ ] Remove
next.config.js/next.config.ts - [ ] Remove
app/directory (replaced bysrc/routes/) - [ ] Remove
middleware.ts(replaced bysrc/start.ts) - [ ] Verify no
next/*imports remain - [ ] Run
npm run devand check all routes - [ ] Verify server-only code is inside
createServerFn(not bare in components/loaders) - [ ] Check that
<Scripts />is in the root route<body>
Common Mistakes
1. CRITICAL: Keeping Server Component mental model
2. CRITICAL: Using "use server" directive
3. HIGH: Interpolating params into Link href
Cross-References
- react-start — full React Start setup
@tanstack/start-client-core#start-core/server-functions— server function patterns@tanstack/start-client-core#start-core/execution-model— isomorphic execution
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingpackages/react-start/skills/lifecycle/migrate-from-nextjs/SKILL.md
Popularity
- Repository stars
- 13,986
- Repository forks
- 1,618
- 7-day trend score
- 48
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 16 Mar 2026, 8 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/tanstack/router/migrate-from-nextjs)