vite.config.ts, and adds npm scripts.
Usage
Options
number
default:"3001"
Dev server port for the vinext script. Can also use the short form Creates a
-p.dev:vinext script that runs on this port (Next.js dev continues to use port 3000).flag
Skip the compatibility check step.By default, vinext runs a compatibility scan before migration. Use this to skip it.
flag
Overwrite existing By default, vinext skips config generation if
vite.config.ts if it exists.vite.config.ts already exists.flag
Show help for this command. Can also use
-h.What It Does
The init command automates project migration:1. Compatibility Check
Scans your project and shows a compatibility report:2. Dependency Installation
Installs required packages:3. ESM Configuration
Vite requires ESM. vinext automatically:-
Renames CJS config files to
.cjsextension:next.config.js→next.config.cjspostcss.config.js→postcss.config.cjstailwind.config.js→tailwind.config.cjs
-
Adds
"type": "module"to package.json:
4. Script Addition
Adds vinext scripts topackage.json without overwriting existing ones:
5. Config Generation
Generates a minimalvite.config.ts:
vinext() plugin auto-detects App Router and registers @vitejs/plugin-rsc if needed.
If
vite.config.ts already exists, vinext skips generation unless you use --force.Examples
Basic Migration
Migrate with all defaults:Custom Port
Use a different dev server port:Skip Compatibility Check
Skip the check if you’ve already runvinext check:
Force Overwrite Config
Overwrite existingvite.config.ts:
Non-Destructive Migration
vinext init is non-destructive:- Does NOT modify:
next.config.*,tsconfig.json, source files - Does NOT remove: Next.js dependencies or scripts
- Safe to run: Your Next.js setup continues to work
After Migration
Start Development Server
Build for Production
Deploy to Cloudflare Workers
Manual Migration Steps
If you prefer manual setup:1. Install Dependencies
2. Add “type”: “module”
Editpackage.json:
3. Rename CJS Configs
4. Create vite.config.ts
5. Add Scripts
Editpackage.json:
6. Start Dev Server
Troubleshooting
”Cannot use import statement outside a module”
You have CommonJS files withrequire() statements. Either:
-
Rename them to
.cjs: -
Or convert to ESM:
“Module not found: @vitejs/plugin-rsc”
For App Router projects, ensure the RSC plugin is installed:vinext dev Fails on Port 3001
Port is already in use. Use a different port:Type Errors After Migration
Run TypeScript typecheck:- Missing types:
npm install -D @types/node - Vite types: Add to
tsconfig.json:
Rollback
To remove vinext and go back to Next.js only:- Remove vinext scripts from
package.json - Remove
"type": "module"frompackage.json - Rename configs back:
- Remove dependencies:
- Delete
vite.config.ts
Next Steps
dev Command
Start the development server
check Command
Understand the compatibility report