Configuration Guide
vinext automatically loads your Next.js configuration and translates it to Vite. This guide covers both Next.js config options and Vite customization.Next.js Configuration
vinext loads and respects your existingnext.config.js:
next.config.js(CommonJS)next.config.mjs(ES modules)next.config.ts(TypeScript)next.config.cjs(CommonJS with .cjs extension)
Supported Config Options
basePath
Add a path prefix to your application:
/→/docs//about→/docs/about<Link href="/blog">→/docs/blog
trailingSlash
Control URL trailing slashes:
env
Add custom environment variables:
process.env.CUSTOM_KEY in both server and client code.
NEXT_PUBLIC_* variables are always available on the client. Other variables are server-only unless explicitly added to env.output
Control build output format:
'export'- Full static export (no server required)'standalone'- Self-contained server (Node.js deployment)undefined- Default (SSR + static optimization)
images
Configure image optimization:
redirects
URL redirects with pattern matching:
- Path parameters (
:param) - Wildcards (
:path*for catch-all) - Conditional redirects with
has/missing
rewrites
Rewrite URLs without changing the browser address:
headers
Add custom HTTP headers:
i18n
Internationalization routing (Pages Router only):
- Prefixes URLs with locale (
/fr/about,/de/contact) - Detects locale from
Accept-Languageheader - Stores preference in
NEXT_LOCALEcookie
App Router uses a different i18n approach. See Next.js i18n docs for App Router patterns.
cacheComponents
Enable the “use cache” directive (Next.js 16+):
Function-Form Config
Configs can be functions (useful for per-environment settings):phase-development-server-vinext devphase-production-build-vinext buildphase-production-server-vinext start
Vite Configuration
For advanced customization, create avite.config.ts:
Auto-Generated Config
Runningvinext init or vinext deploy auto-generates a minimal vite.config.ts.
App Router:
TypeScript Path Aliases
vinext automatically resolves TypeScript path aliases fromtsconfig.json:
vite-tsconfig-paths, which vinext injects automatically.
MDX Support
vinext auto-detects MDX usage and configures@mdx-js/rollup with plugins from your Next.js config:
@mdx-js/rollup automatically.
For manual MDX configuration:
CSS and Styling
vinext supports all Vite CSS features out of the box:Tailwind CSS
CSS Modules
PostCSS
Createpostcss.config.cjs (note the .cjs extension for ESM projects):
Build Options
Dev Server Options
Optimization
Aliasing Modules
For native modules that can’t run in Workers:vinext automatically stubs common native modules (
sharp, resvg, satori, lightningcss, @napi-rs/canvas) during vinext deploy.Environment-Specific Config
Environment Variables
Development (.env.local)
Production (.env.production)
Loading Priority
.env.local(highest priority, not committed).env.productionor.env.development(environment-specific).env(shared defaults)
Runtime Access
vinext Plugin Options
The vinext plugin accepts configuration:Currently, vinext auto-configures based on your Next.js setup and doesn’t require explicit options. Future versions may add customization points.
Migration from Next.js Config
Webpack Config
Next.js:Experimental Options
Most Next.js experimental options are not needed in vinext: Next.js:Troubleshooting
Config Not Loading
Problem: Changes tonext.config.js aren’t reflected
Solution: Restart the dev server. Config is loaded once at startup.
Path Alias Not Working
Problem: Import using@/... fails
Solution: Ensure tsconfig.json has correct paths config and baseUrl is set.
PostCSS Error
Error:Error: Cannot find module 'postcss.config.js'
Solution: Rename to postcss.config.cjs if your project has "type": "module" in package.json.
Environment Variable Not Available
Problem:process.env.MY_VAR is undefined in client code
Solution: Client-side variables must start with NEXT_PUBLIC_:
Next Steps
Deployment
Deploy your configured application
Cloudflare Workers
Deploy to Cloudflare with advanced config
Static Export
Configure static site generation
Vite Documentation
Complete Vite configuration reference