Skip to main content
vinext reimplements the Next.js module API surface using Vite, allowing you to use standard next/* imports with full compatibility.

Available Modules

All next/* imports are automatically shimmed by vinext:

How It Works

vinext’s Vite plugin intercepts next/* imports and resolves them to shim implementations:
The shims provide API-compatible implementations that work with:
  • Vite’s module system (ESM, HMR, multi-environment builds)
  • Standard Web APIs (Request, Response, Headers)
  • Multiple runtimes (Node.js, Cloudflare Workers, Deno)

Compatibility Notes

Full Compatibility

Most Next.js APIs work identically:
  • All navigation APIs (useRouter, usePathname, Link)
  • Server Components APIs (headers, cookies, notFound)
  • Middleware (NextRequest, NextResponse)
  • Image optimization and lazy loading
  • Font optimization (Google Fonts and local)

Runtime Differences

vinext uses AsyncLocalStorage for request context isolation. This works in:
  • Node.js 16+ (native)
  • Cloudflare Workers (via polyfill)
  • Deno (native)
In environments without ALS support, a fallback to module-level state is used (not concurrency-safe).
Local image optimization routes through /_vinext/image:
  • Dev mode: Serves original files
  • Cloudflare Workers: Uses Cloudflare Images binding
  • Custom backends: Implement your own handler
Remote images use @unpic/react for CDN-native transforms.
Google Fonts:
  • Dev: Loads from Google Fonts CDN
  • Production: Self-hosted via build-time fetch (no runtime requests)
Local fonts are bundled as assets and served with proper caching headers.

Extension Points

Custom Cache Handler

Swap the cache backend for Redis, DynamoDB, etc:

Image Optimization Handler

Intercept /_vinext/image requests in your server:

Middleware Context

Access platform-specific context in middleware:

Type Safety

All shims are fully typed with TypeScript:
Types are compatible with @types/react and the Next.js type definitions.