Migrate Next.js to vinext
vinext reimplements the Next.js API surface on Vite. Existing
,
, and
work as-is — migration is a package swap, config generation, and ESM conversion. No changes to application code required.
FIRST: Verify Next.js Project
Confirm
is in
or
in
. If not found, STOP — this skill does not apply.
Detect the package manager from the lockfile:
| Lockfile | Manager | Install | Uninstall |
|---|
| pnpm | | |
| yarn | | |
| / | bun | | |
| or none | npm | | |
Detect the router: if an
directory exists at root or under
, it's App Router. If only
exists, it's Pages Router. Both can coexist.
Quick Reference
| Command | Purpose |
|---|
| Scan project for compatibility issues, produce scored report |
| Automated migration — installs deps, generates config, converts to ESM |
| Development server with HMR |
| Production build (multi-environment for App Router) |
| Local production server |
| Build and deploy to Cloudflare Workers |
Phase 1: Check Compatibility
Run
(install vinext first if needed via
). Review the scored report. If critical incompatibilities exist, inform the user before proceeding.
See references/compatibility.md for supported/unsupported features and ecosystem library status.
Phase 2: Automated Migration (Recommended)
- Runs for a compatibility report
- Installs as a devDependency (and for App Router)
- Adds to package.json
- Renames CJS config files (e.g., → ) to avoid ESM conflicts
- Adds and scripts to package.json
- Generates a minimal
This is non-destructive — the existing Next.js setup continues to work alongside vinext. Use the
script to test before fully switching over.
If
succeeds, skip to Phase 4 (Verify). If it fails or the user prefers manual control, continue to Phase 3.
Phase 3: Manual Migration
Use this as a fallback when
doesn't work or the user wants full control.
3a. Replace packages
bash
# Example with npm:
npm uninstall next
npm install vinext
npm install -D vite
# App Router only:
npm install -D @vitejs/plugin-rsc
3b. Update scripts
Replace all
commands in
scripts:
| Before | After | Notes |
|---|
| | Dev server with HMR |
| | Production build |
| | Local production server |
| | Delegates to eslint/oxlint |
3c. Convert to ESM
Add
to package.json. Rename any CJS config files:
- →
- →
- Any other config that uses
3d. Generate vite.config.ts
See references/config-examples.md for config variants per router and deployment target.
Pages Router (minimal):
ts
import vinext from "vinext";
import { defineConfig } from "vite";
export default defineConfig({ plugins: [vinext()] });
App Router (minimal):
ts
import vinext from "vinext";
import { defineConfig } from "vite";
export default defineConfig({ plugins: [vinext()] });
vinext auto-registers
for App Router when the
option is not explicitly
. No manual RSC plugin config needed for local development.
Phase 4: Cloudflare Deployment (Optional)
If the user wants to deploy to Cloudflare Workers, the simplest path is
— it auto-generates
, worker entry, and Vite config if missing, installs
and
, then builds and deploys.
For manual setup or custom worker entries, see references/config-examples.md.
Phase 5: Verify
- Run to start the development server
- Confirm the server starts without errors
- Navigate key routes and check functionality
- Report the result to the user — if errors occur, share full output
See references/troubleshooting.md for common migration errors.
Known Limitations
| Feature | Status |
|---|
| optimization | Remote images via @unpic; no build-time optimization |
| CDN-loaded, not self-hosted |
| Domain-based i18n | Not supported; path-prefix i18n works |
| Not supported; use Vitest |
| Turbopack/webpack config | Ignored; use Vite plugins instead |
| / | Route segment configs ignored |
| PPR (Partial Prerendering) | Use directive instead (Next.js 16 approach) |
Anti-patterns
- Do not modify , , or application code. vinext shims all imports — no import rewrites needed.
- Do not rewrite imports to in application code. Imports like , , resolve automatically.
- Do not copy webpack/Turbopack config into Vite config. Use Vite-native plugins instead.
- Do not skip the compatibility check. Run before migration to surface issues early.
- Do not remove unless replacing it with or . vinext reads it for redirects, rewrites, headers, basePath, i18n, images, and env config.