Vite Configuration
For basic usage, vinext auto-detects yourapp/ or pages/ directory and generates a Vite config automatically. No vite.config.ts required.
For advanced usage (custom plugins, Cloudflare Workers deployment, build options), create a vite.config.ts file.
Basic Configuration
Pages Router
App Router (Development)
For local development with App Router:App Router (Cloudflare Workers)
For Cloudflare Workers deployment:vinext Plugin Options
Thevinext() plugin accepts no configuration options. It reads your next.config.js automatically.
Common Customizations
Path Aliases
vinext respects yourtsconfig.json path aliases. For manual configuration:
MDX Support
vinext auto-detects@next/mdx in your next.config.js and injects @mdx-js/rollup automatically. For manual configuration:
Environment Variables
Environment variables with theNEXT_PUBLIC_ prefix are exposed to the client automatically:
Build Options
CSS Processing
PostCSS Configuration
vinext loadspostcss.config.js automatically. When using ESM ("type": "module"), rename CJS config files to .cjs:
Virtual Modules
vinext provides virtual entry points for the RSC plugin:virtual:vinext-rsc-entry- RSC environment entry (react-server)virtual:vinext-app-ssr-entry- SSR environment entry (node/workers)virtual:vinext-app-browser-entry- Client environment entry (browser)virtual:vinext-server-entry- Pages Router server entry
Multi-Environment Builds
App Router uses@vitejs/plugin-rsc for multi-environment builds:
- RSC environment (
rsc) - React Server Components rendering - SSR environment (
ssr) - HTML generation - Client environment (
client) - Browser hydration
vinext build (not vite build directly).
Production Build
Always use the vinext CLI for production builds:vite build or vite build --ssr directly. The vinext CLI calls createBuilder() which runs the 5-step multi-environment build pipeline.
Common Patterns
Tailwind CSS
Bundle Analysis
Custom Server Middleware
Use Vite’sconfigureServer hook:
Migrating from Next.js
If you havenext.config.js options that need Vite equivalents:
Related
- next.config.js - Next.js configuration
- Route Segment Config - Per-route configuration
- Vite Documentation - Official Vite config reference