jovidecroock/pracht/migrate-nextjs
Claude Code and agent skill by jovidecroock/pracht
- community
- ext:[{"type":"config","description":"Configuration overrides"}]
Checking that the SKILL.md file is still in the repository.
Migrate a Next.js app (App or Pages Router) to pracht: pages, layouts, middleware, API routes, data fetching, metadata, and React to Preact. Use for "migrate from Next.js", "convert my Next app", "port from next to pracht", "switch from next".
Install
npx vskill@latest install jovidecroock/pracht/migrate-nextjsSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as jovidecroock/pracht/migrate-nextjs.
Migrate Next.js to pracht
Migrate in phases: setup → shells → routes → client components → API → middleware → manifest → patterns → cleanup. Read each Next.js source file before converting it; never infer from the filename. Prefer the simplest pracht equivalent, and when a Next.js feature has no equivalent, say so and propose an alternative instead of inventing one.
MCP: if pracht dev-mcp is registered, prefer its inspect_*, generate_*, doctor, and verify tools to the CLI.
Step 0: Assess the source
Read next.config.* and package.json (React/Next versions, deps), then map the tree: app/ (App Router), pages/ (Pages Router), middleware.ts, app/api/ or pages/api/. Note which patterns are in use — "use client", async server components, generateStaticParams, generateMetadata/metadata, "use server" actions — and the third-party integrations (auth, CMS, DB, analytics). Confirm scope with the user if the app has more than ~20 routes.
Agent tools alone do not require a router migration; use the standalone host: <https://pracht.resynapse.dev/docs/standalone-capabilities>.
Fast path: Pages Router
pagesDir makes a pages-router source near-drop-in — Phase 7 is then automatic:
pracht({ pagesDir: "/src/pages" })invite.config.ts; copypages/to
src/pages/.
_app.tsx→ pracht shell shape (Shellexport takingchildren). A
subdirectory _app scopes a shell to that subtree (blog/_app.tsx → "pages:blog"), where App Router layout.tsx lands — but shells replace rather than nest, so it repeats the chrome, head(), and headers() it needs.
getServerSideProps/getStaticProps→loaderexport.export const RENDER_MODE = "ssg"on static pages ("ssr"is the
default). For time-revalidated pages export RENDER_MODE = "isg" plus a positive integer REVALIDATE in seconds; webhook policies require ejecting to a manifest.
middleware.ts→ a root-levelsrc/pages/_middleware.tsexporting a
MiddlewareFn (Phase 6). It runs on every page route; API routes are not wrapped. Move config.matcher checks into the body and compare stripBase(url.pathname). A nested _middleware, a _middleware/ directory, and a missing export are build/doctor/verify errors.
- Other
_-prefixed files and directories are reserved: pracht ignores the
subtree. Capabilities live in src/capabilities/ (auto-discovered, self-named); agents / constraints in src/pages/_app.config.ts.
- Run the dev server, iterate, and optionally eject later with
generateRoutesFile.
Concept mapping
| Next.js | pracht | Notes | |
|---|---|---|---|
pages/ directory | pagesDir plugin option | Auto-discovers routes from the file system | |
app/page.tsx | src/routes/*.tsx + route() in manifest | File is a module; wiring is explicit | |
app/layout.tsx | src/shells/*.tsx + shells in defineApp (pages: _app.tsx per directory) | Named shells; a directory _app replaces its parent. Layout data: shell loader + useShellData() | |
app/loading.tsx | Loading export on the shell | SSR placeholder for SPA routes until the client router takes over | |
app/error.tsx | ErrorBoundary export in route module | Same concept, different wiring | |
app/not-found.tsx | notFound: in defineApp (or pages/404.tsx in pagesDir mode) | Not a route — never matches a URL, so it cannot shadow static assets | |
middleware.ts | src/middleware/*.ts + middleware in defineApp (or src/pages/_middleware.ts in pagesDir mode) | Named, applied per route/group; the pages-mode file runs on every page route | |
app/api/*/route.ts | src/api/*.ts with GET/POST exports | Auto-discovered, no manifest entry | |
generateStaticParams | getStaticPaths() export | Returns RouteParams[] of param objects | |
generateMetadata | head() export | Returns { title, meta } | |
| Server Components | loader() export | Data fetching moves to the loader; the component is a Preact component | |
useEffect + fetch, SWR, or client queries for page data | loader() export | Loader data and the route's code load together on navigation; a mount-time fetch waits for the code. Promise.all independent calls; defer() only secondary content | |
"use server" actions | API routes + <Form> / fetch | Mutations move to src/api/*; return Response objects | |
"use client" (few, mostly-server app) | hydration: "islands" + src/islands/ | Only islands ship JS; see Phase 4 | |
revalidatePath / res.revalidate() | webhookRevalidate() + POST /__pracht/revalidate | On-demand ISG; combinable with timeRevalidate(seconds) | |
useRouter() (next/navigation) | useNavigate() | Takes a path, or { route: "id" } after pracht typegen | |
useSearchParams() | useSearchParams() | Read-only; set with useSetSearchParams(). SSG gets the browser query after hydration. For typed values export a search schema and read args.search / useSearch() | |
useParams() | useParams() | Direct equivalent; also params in loader args | |
next/link <Link> | <Link route="..." params={{…}}> or plain <a> | Prefer typed <Link> after pracht typegen; the router intercepts same-origin anchors | |
next/link prefetch={false} | <Link prefetch="none"> | Default "intent" (hover/focus); also "viewport", "render" | |
useLinkStatus() / pending UI | useNavigation() | { state, location, formData } — progress bars, optimistic UI | |
next/image | <Image> from @pracht/image | Responsive srcsets; Node, Cloudflare, Vercel, Netlify, or passthrough loaders | |
next/head or Metadata API | head() export on route/shell | Per-route and per-shell head merging | |
next/script <Script> | <Script> from @pracht/core | beforeHydration (≈ beforeInteractive), afterHydration (≈ afterInteractive, default), idle (≈ lazyOnload), visible | |
cookies() / headers() | request.headers in loader/middleware/API args | No separate API — read the standard Request | |
className | class | Preact uses the class attribute | |
react / react-dom imports | preact/hooks, preact/compat | Same hook APIs | |
import React from "react" | Remove | The Vite plugin handles JSX |
Scroll restoration on back/forward is automatic. <Link> also takes preserveScroll (skip the scroll-to-top reset) and viewTransition (wrap the navigation in document.startViewTransition() where supported).
Phase 1: Project setup
Create src/routes.ts (manifest), src/routes/, src/shells/, src/middleware/, src/api/, and a vite.config.ts whose plugins array contains pracht() from @pracht/vite-plugin. Then:
- Dependencies: drop
react/react-domforpreact; dropnextfor
@pracht/core (runtime), @pracht/cli (the pracht bin), @pracht/vite-plugin, and a target adapter such as @pracht/adapter-node. There is no package named pracht. Add @pracht/image if the app used next/image, and sharp only for the built-in Node optimization endpoint or build-time ?pracht imports.
- Scripts:
dev→pracht dev,build→pracht build,start→
node dist/server/server.js (Node) or the platform deploy command; add preview → pracht preview.
- Delete
next.config.*,next-env.d.ts,.next/. - In
tsconfig.json,"jsx": "preserve"→"jsx": "react-jsx"with
"jsxImportSource": "preact".
Phase 2: Layouts → shells
Shells must NOT render <html>, <head>, or <body> — the framework owns the document, so move anything from RootLayout's document tags into head(). Register as defineApp({ shells: { main: "./shells/main.tsx" } }).
Phase 3: Pages → route modules
An async page that fetches and exports generateMetadata becomes three exports — the fetch moves to loader, the metadata to head, the JSX stays in the default export:
Components are never async — data arrives as the data prop.
Phase 4: Client components
Drop the "use client" directive (pracht has no such concept), and repoint imports: react → preact/hooks for hooks, react/react-dom → preact/compat for everything else. The component body is otherwise unchanged.
Islands: if the source is mostly server components with a handful of "use client" leaves, do not silently regress those pages to full-page hydration. Set hydration: "islands" on the route (or export const HYDRATION = "islands" in pages mode) and move the interactive components into src/islands/ — the rest renders as inert HTML.
Phase 5: API routes
app/api/users/route.ts → src/api/users.ts, dynamic segments included (app/api/users/[id]/route.ts → src/api/users/[id].ts). Handlers take ApiRouteArgs and use web standards throughout:
NextRequest → the standard Request from ApiRouteArgs; NextResponse.json() → Response.json(). No manifest wiring — API routes are auto-discovered.
Phase 6: Middleware
NextResponse.redirect() → return redirect("/path", { request }); NextResponse.next() → return next(). Path matching moves out of config.matcher and into manifest assignment: group({ middleware: ["auth"] }, [route("/dashboard", …)]). Middleware wraps the handler, so await next() returns the response for tracing.
In pagesDir mode the same MiddlewareFn goes in a root-level src/pages/_middleware.ts, applied to every page route (API routes stay unwrapped). Do not migrate a per-request auth matcher onto an ssg/isg page and call it protected: that document runs middleware only at build/revalidation, with a sanitized request. Keep such pages ssr/spa, or keep a separately verified edge gate. Pure static exports have no request runtime.
Phase 7: Route manifest
Skip this phase for pagesDir projects. Prefer pracht generate route --path ... --render ... (plus --shell/--middleware/ --loader) per page — it creates a wired skeleton and updates src/routes.ts — then port the Next.js bodies into the generated files. Hand-write manifest entries only for shapes the generator cannot express.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/migrate-nextjs/SKILL.md
Popularity
- Repository stars
- 68
- Repository forks
- 2
- 7-day trend score
- 21
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 16 May 2026, 6 months ago.
Extension points
configConfiguration overrides
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/jovidecroock/pracht/migrate-nextjs)