Documentation Index
Fetch the complete documentation index at: https://mintlify.com/cloudflare/vinext/llms.txt
Use this file to discover all available pages before exploring further.
next.config.js/ts Configuration
vinext loads and parses your existingnext.config.js, next.config.ts, next.config.mjs, or next.config.cjs file automatically. The configuration is loaded at both dev and build time.
Configuration File
Create a configuration file in your project root:Function Form
Configs can be functions that receive phase and default config:Configuration Options
env
Type:Record<string, string>
Additional environment variables to expose to the application. These are inlined at build time.
basePath
Type:string
URL path prefix for your application. All routes, links, and assets are automatically prefixed.
- Routes:
/docs/about,/docs/api/users - Links:
<Link href="/about">renders as/docs/about - Assets:
/logo.pngbecomes/docs/logo.png
trailingSlash
Type:booleanDefault:
false
Whether to add trailing slashes to URLs. When enabled, vinext issues 308 redirects to the canonical form.
trailingSlash: true:
/about→ 308 redirect to/about//api/users→ 308 redirect to/api/users/
i18n
Type:NextI18nConfig | undefined
Internationalization routing configuration (Pages Router only).
i18n Options
locales (required)Type:
string[]List of supported locales.
defaultLocale (required)Type:
stringDefault locale used when no locale prefix is in the URL.
localeDetectionType:
booleanDefault:
trueAuto-detect locale from
Accept-Language header.
domainsType:
Array<{ domain: string; defaultLocale: string; locales?: string[]; http?: boolean }>Domain-based locale routing.
redirects
Type:() => Promise<NextRedirect[]> | NextRedirect[]
URL redirect rules. Supports async functions.
Redirect Options
source (required)Type:
stringURL pattern to match. Supports route parameters (
:param) and wildcards (*).
destination (required)Type:
stringRedirect target URL. Can reference captured parameters.
permanent (required)Type:
booleantrue = 308 redirect, false = 307 redirect.
hasType:
HasCondition[]Conditional matching based on headers, cookies, query params, or host.
missingType:
HasCondition[]Inverse of
has — match when conditions are NOT present.
HasCondition
rewrites
Type:() => Promise<NextRewrite[] | RewriteObject> | NextRewrite[] | RewriteObject
URL rewrite rules. Rewrites change the request path without changing the browser URL.
Phased Rewrites
Control when rewrites run relative to file-system routes:Rewrite Options
Same as redirects except nopermanent field.
headers
Type:() => Promise<NextHeader[]> | NextHeader[]
Custom HTTP response headers.
images
Type:ImageConfig
Image optimization configuration.
Image Options
remotePatternsType:
Array<{ protocol?: string; hostname: string; port?: string; pathname?: string; search?: string }>Allowed remote image patterns.
domainsType:
string[]Legacy alternative to
remotePatterns. Simple hostname allowlist.
unoptimizedType:
booleanDefault:
falseDisable image optimization entirely.
Remote images work via @unpic/react (28 CDN providers). Local images use
<img> with srcSet. No build-time optimization occurs.output
Type:'export' | 'standalone' | undefined
Build output mode.
'export': Static export (all routes pre-rendered to HTML)'standalone': Single server bundle (default forvinext build)undefined: Standard build
cacheComponents
Type:booleanDefault:
false
Enable Cache Components (Next.js 16+). When true, enables the "use cache" directive for pages, components, and functions.
experimental.ppr and experimental.dynamicIO flags.
transpilePackages
Type:string[]
Packages to transpile. Vite handles this natively via optimizeDeps.include.
Loading Behavior
vinext searches for config files in this order:next.config.tsnext.config.mjsnext.config.jsnext.config.cjs
ESM vs CJS
vinext attempts ESM dynamic import first. If the file uses CJS constructs (require, module.exports), it falls back to createRequire for proper CommonJS loading.
This ensures compatibility with plugin wrappers like @next/mdx and Nextra.
Type Definitions
NextConfig
ResolvedNextConfig
Fully resolved configuration with all async values awaited:Functions
loadNextConfig
null if no config file is found.
resolveNextConfig
NextConfig into a fully-resolved ResolvedNextConfig. Awaits async functions for redirects, rewrites, and headers.
Related
- Vite Configuration - Vite-specific config options
- Route Segment Config - Per-route configuration
- Deploying to Cloudflare - Cloudflare Workers deployment