Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

migrate-from-nextjs

БесплатноБез исполняемых скриптовНе проверен

Step-by-step migration from Next.js App Router to TanStack Start: route definition conversion, API mapping, server function conversion from Server Actions…

TanStackот TanStack★ 15 408 звёзд на GitHub

Об этом скилле

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 use createServerFn. This is the opposite of Next.js Server Components, where code is server-only by default.

CRITICAL: TanStack Start uses createServerFn, 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
git checkout -b migrate-to-tanstack-start
  • Install TanStack Start
npm i @tanstack/react-start @tanstack/react-router
npm i -D vite @vitejs/plugin-react
  • Remove Next.js
npm uninstall next @next/font @next/image

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:

// vite.config.ts
import { defineConfig } from 'vite'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import viteReact from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [
    tanstackStart(), // MUST come before react()
    viteReact(),
  ],
})

Update package.json:

{
  "type": "module",
  "scripts": {
    "dev": "vite dev",
    "build": "vite build",
    "start": "node .output/server/index.mjs"
  }
}

Step 2: Router Factory

// src/router.tsx
import { createRouter } from '@tanstack/react-router'
import { routeTree } from './routeTree.gen'

export function getRouter() {
  const router = createRouter({
    routeTree,
    scrollRestoration: true,
  })
  return router
}

Step 3: Convert Layout → Root Route

Next.js:

// app/layout.tsx
export const metadata = { title: 'My App' }
export default function RootLayout({ children }) {
  return (
    <html>
      <body>{children}</body>
    </html>
  )
}

TanStack Start:

// src/routes/__root.tsx
import type { ReactNode } from 'react'
import {
  Outlet,
  createRootRoute,
  HeadContent,
  Scripts,
} from '@tanstack/react-router'

export const Route = createRootRoute({
  head: () => ({
    meta: [
      { charSet: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { title: 'My App' },
    ],
  }),
  component: RootComponent,
})

function RootComponent() {
  return (
    <html>
      <head>
        <HeadContent />
      </head>
      <body>
        <Outlet />
        <Scripts />
      </body>
    </html>
  )
}

Step 4: Convert Pages → File Routes

Next.js:

// app/posts/[id]/page.tsx
export default function PostPage({ params }: { params: { id: string } }) {
  // ...
}

TanStack Start:

// src/routes/posts/$postId.tsx
import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/posts/$postId')({
  component: PostPage,
})

function PostPage() {
  const { postId } = Route.useParams()
  // ...
}

Key differences:

  • Dynamic segments use $param not [param]
  • Params accessed via Route.useParams() not component props
  • Route path in filename uses . or / separators

Step 5: Convert Server Actions → Server Funct

Полный SKILL.md на GitHub

Установить migrate-from-nextjs в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл migrate-from-nextjs?

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.

Как установить скилл migrate-from-nextjs?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл migrate-from-nextjs запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить migrate-from-nextjs с