Installation
This guide covers everything you need to know about installing and configuring vinext, from basic setup to advanced customization.Prerequisites
Before you begin, make sure you have:- Node.js 18+ installed
- An existing Next.js project (or create a new one)
- Basic familiarity with Next.js and Vite
vinext requires React 19.2.0+, React DOM 19.2.0+, and Vite 7.0.0+ as peer dependencies.
Installation Methods
Method 1: Using vinext init (Recommended)
Thevinext init command automates the entire migration process:
1
Install vinext
2
Run the migration command
- Run compatibility check — Scans your project for potential issues
- Install dependencies — Adds
viteand@vitejs/plugin-rsc(for App Router) as devDependencies - Configure ESM — Adds
"type": "module"topackage.json - Rename CJS configs — Renames files like
postcss.config.jsto.cjsto avoid ESM conflicts - Add npm scripts — Adds
dev:vinextandbuild:vinexttopackage.json - Generate vite.config.ts — Creates a minimal Vite configuration
3
Start developing
http://localhost:3001 (configurable with --port).Method 2: Manual Installation
For more control over the setup process:1
Install vinext and peer dependencies
2
Update package.json
Add
"type": "module" to enable ESM:package.json
3
Create vite.config.ts (App Router only)
If your project uses the App Router (
app/ directory), create a vite.config.ts:vite.config.ts
For Pages Router projects, no
vite.config.ts is needed. vinext auto-configures everything.4
Handle CJS config files
If you have CommonJS config files (like
postcss.config.js), rename them to .cjs to avoid conflicts:Configuration
Basic Configuration
For most projects, novite.config.ts is required. vinext auto-detects your project structure and configures Vite automatically.
If you need custom Vite configuration:
vite.config.ts
App Router Configuration
For App Router projects with React Server Components:vite.config.ts
Cloudflare Workers Configuration
For deployment to Cloudflare Workers, add the Cloudflare Vite plugin:vite.config.ts
Migrating from Next.js
File Structure
Your existing file structure works as-is:next.config.js
Your existingnext.config.js (or .ts/.mjs) works with vinext. Most configuration options are supported:
next.config.js
Environment Variables
Environment variables work the same as in Next.js:.env.local
NEXT_PUBLIC_*variables are inlined at build time (client-side)- Other variables are available server-side only
TypeScript Configuration
Your existingtsconfig.json works with vinext. Path aliases are automatically resolved via vite-tsconfig-paths:
tsconfig.json
Deploying to Cloudflare Workers
vinext makes it incredibly easy to deploy to Cloudflare Workers:1
One-command deployment
- Detects App Router or Pages Router
- Generates
wrangler.jsoncand worker configuration - Installs required dependencies
- Builds your application
- Deploys to Cloudflare Workers
2
Deploy to preview environment
Test your deployment in a preview environment:
3
Custom Worker name
Deploy with a custom name:
Deploy Options
Traffic-Aware Pre-Rendering (Experimental)
TPR queries Cloudflare zone analytics at deploy time to find which pages actually get traffic, pre-renders only those, and uploads them to KV cache:Caching with Cloudflare KV
For production ISR caching, use the built-in KV cache handler:app/layout.tsx
wrangler.jsonc:
wrangler.jsonc
Compatibility Checking
Before fully committing to vinext, check your project for compatibility:- ✅ Supported features you’re using
- 🟡 Partially supported features
- ❌ Unsupported features that need attention
Example Output
Advanced Configuration
Custom Vite Plugins
Add any Vite plugins you need:vite.config.ts
MDX Support
For MDX support (e.g., with Nextra), add the MDX plugin:vite.config.ts
Path Aliases
Path aliases from yourtsconfig.json are automatically resolved. No additional configuration needed!
tsconfig.json
Troubleshooting
Dual Package Hazard
If you see “Invalid hook call” errors or React warnings about multiple React copies:vite.config.ts
ESM/CJS Conflicts
If you see errors like “require() of ES Module not supported”:- Add
"type": "module"topackage.json - Rename
.jsconfig files to.cjs(e.g.,postcss.config.cjs) - Use
export defaultinstead ofmodule.exportsin config files
Native Node Modules
Some packages (sharp, resvg, satori, lightningcss, @napi-rs/canvas) crash Vite’s RSC dev environment. These are auto-stubbed duringvinext deploy.
For local development, dynamic OG image routes using these packages work in production builds but not in dev mode.
TypeScript Errors
If you see TypeScript errors about missing types:Build Failures
If your build fails:- Check that you have all peer dependencies installed
- For App Router, ensure
@vitejs/plugin-rscis installed - Run
vinext checkto identify compatibility issues - Check the build output for specific error messages
Next Steps
CLI Reference
Explore all vinext CLI commands
API Coverage
See what Next.js features are supported
Live Examples
Browse deployed examples on Cloudflare Workers
GitHub Repository
View the source code and contribute