jovidecroock/pracht/migrate-nextjs

Claude Code and agent skill by jovidecroock/pracht

Trust tier 2
  • community
  • ext:[{"type":"config","description":"Configuration overrides"}]
LLM review pending
Source check pending

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-nextjs

Semi-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:

  1. pracht({ pagesDir: "/src/pages" }) in vite.config.ts; copy pages/ to

src/pages/.

  1. _app.tsx → pracht shell shape (Shell export taking children). 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.

  1. getServerSideProps/getStaticProps → loader export.
  2. 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.

  1. middleware.ts → a root-level src/pages/_middleware.ts exporting 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.

  1. 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.

  1. Run the dev server, iterate, and optionally eject later with

generateRoutesFile.

Concept mapping

Next.jsprachtNotes
pages/ directorypagesDir plugin optionAuto-discovers routes from the file system
app/page.tsxsrc/routes/*.tsx + route() in manifestFile is a module; wiring is explicit
app/layout.tsxsrc/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.tsxLoading export on the shellSSR placeholder for SPA routes until the client router takes over
app/error.tsxErrorBoundary export in route moduleSame concept, different wiring
app/not-found.tsxnotFound: in defineApp (or pages/404.tsx in pagesDir mode)Not a route — never matches a URL, so it cannot shadow static assets
middleware.tssrc/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.tssrc/api/*.ts with GET/POST exportsAuto-discovered, no manifest entry
generateStaticParamsgetStaticPaths() exportReturns RouteParams[] of param objects
generateMetadatahead() exportReturns { title, meta }
Server Componentsloader() exportData fetching moves to the loader; the component is a Preact component
useEffect + fetch, SWR, or client queries for page dataloader() exportLoader 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" actionsAPI routes + <Form> / fetchMutations 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/revalidateOn-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 UIuseNavigation(){ state, location, formData } — progress bars, optimistic UI
next/image<Image> from @pracht/imageResponsive srcsets; Node, Cloudflare, Vercel, Netlify, or passthrough loaders
next/head or Metadata APIhead() export on route/shellPer-route and per-shell head merging
next/script <Script><Script> from @pracht/corebeforeHydration (≈ beforeInteractive), afterHydration (≈ afterInteractive, default), idle (≈ lazyOnload), visible
cookies() / headers()request.headers in loader/middleware/API argsNo separate API — read the standard Request
classNameclassPreact uses the class attribute
react / react-dom importspreact/hooks, preact/compatSame hook APIs
import React from "react"RemoveThe 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-dom for preact; drop next for

@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

tsx
import type { ShellProps } from "@pracht/core";
export function Shell({ children }: ShellProps) {
return <div class="root"><main>{children}</main></div>;
}
export function head() {
return { title: "My App" };
}

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:

tsx
import type { LoaderArgs, RouteComponentProps } from "@pracht/core";
export async function loader(_args: LoaderArgs) {
const res = await fetch("https://api.example.com/data");
return res.json();
}
export function head({ data }: { data: Awaited<ReturnType<typeof loader>> }) {
return { title: data.title };
}
export default function Page({ data }: RouteComponentProps<typeof loader>) {
return <div class="page">{data.title}</div>;
}

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:

ts
import type { ApiRouteArgs } from "@pracht/core";
export async function GET({ request }: ApiRouteArgs) {
return Response.json(await getUsers());
}

NextRequest → the standard Request from ApiRouteArgs; NextResponse.json() → Response.json(). No manifest wiring — API routes are auto-discovered.

Phase 6: Middleware

ts
import { redirect, type MiddlewareFn } from "@pracht/core";
export const middleware: MiddlewareFn = async ({ request }, next) => {
const session = request.headers.get("cookie")?.includes("session");
if (!session) return redirect("/login", { request });
return next();
};

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.

ts
import { defineApp, group, route } from "@pracht/core";
export const app = defineApp({
shells: { main: () => import("./shells/main.tsx") },
middleware: { auth: () => import("./middleware/auth.ts") },
routes: [
group({ shell: "main" }, [
route("/", () => import("./routes/home.tsx"), { render: "ssg" }),
route("/dashboard", () => import("./routes/dashboard.tsx"), {
render: "ssr",
middleware: ["auth"],
}),
route("/blog/:slug", () => import("./routes/blog-post.tsx"), { render: "isg" }),
]),
],
notFound: { component: () => import("./routes/not-found.tsx"), shell: "main" },
});

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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/jovidecroock/pracht/migrate-nextjs/badge)](https://verified-skill.com/skills/jovidecroock/pracht/migrate-nextjs)

Something wrong with this skill or its page? Tell us.