Skip to main content
Migrates an existing Next.js project to vinext with a one-command setup. Installs dependencies, configures ESM, generates 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 -p.
Creates a 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 vite.config.ts if it exists.
By default, vinext skips config generation if 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:
See the check command for details on what’s checked.

2. Dependency Installation

Installs required packages:

3. ESM Configuration

Vite requires ESM. vinext automatically:
  1. Renames CJS config files to .cjs extension:
    • next.config.jsnext.config.cjs
    • postcss.config.jspostcss.config.cjs
    • tailwind.config.jstailwind.config.cjs
  2. Adds "type": "module" to package.json:
After adding "type": "module", .js files are treated as ESM. If you have CommonJS files, rename them to .cjs or convert to ESM.

4. Script Addition

Adds vinext scripts to package.json without overwriting existing ones:
You can now run:

5. Config Generation

Generates a minimal vite.config.ts:
The 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:
Output:

Custom Port

Use a different dev server port:
Creates:

Skip Compatibility Check

Skip the check if you’ve already run vinext check:

Force Overwrite Config

Overwrite existing vite.config.ts:
This will replace your existing vite.config.ts. Back it up first if you have custom configuration.

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
You can run both Next.js and vinext side-by-side:

After Migration

Start Development Server

Or directly:

Build for Production

Or:

Deploy to Cloudflare Workers

Manual Migration Steps

If you prefer manual setup:

1. Install Dependencies

2. Add “type”: “module”

Edit package.json:

3. Rename CJS Configs

4. Create vite.config.ts

5. Add Scripts

Edit package.json:

6. Start Dev Server

Troubleshooting

”Cannot use import statement outside a module”

You have CommonJS files with require() statements. Either:
  1. Rename them to .cjs:
  2. 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:
Or change the script manually:

Type Errors After Migration

Run TypeScript typecheck:
Common issues:
  • Missing types: npm install -D @types/node
  • Vite types: Add to tsconfig.json:

Rollback

To remove vinext and go back to Next.js only:
  1. Remove vinext scripts from package.json
  2. Remove "type": "module" from package.json
  3. Rename configs back:
  4. Remove dependencies:
  5. Delete vite.config.ts

Next Steps

dev Command

Start the development server

check Command

Understand the compatibility report