# vinext

> vinext is an experimental, MIT-licensed reimplementation of the Next.js API surface on Vite for running existing Next.js apps on Cloudflare Workers and other Vite-compatible deployment targets.

## Overview

vinext is a Next.js API compatibility layer built on Vite. Existing `app/`, `pages/`, `next.config.js`, and `public/` directories can run under a Vite toolchain, but vinext is still under active development and should be evaluated against each application before adoption. Cloudflare Workers has the deepest integration; Node.js and other platforms are available with different support levels, including Nitro-based deployment.

## Key Metrics

| Metric | Value | Context |
| --- | --- | --- |
| Build speed | Up to 4.4x faster | Compared with Next.js 16 using Vite 8 / Rolldown in the project's benchmark setup. |
| Bundle size | 57% smaller | Gzipped client bundle compared with Next.js 16. |
| API coverage | 94% | Reported coverage of the Next.js 16 API surface. |
| Tests | 2,080+ | Vitest and Playwright end-to-end tests. |

## Compatibility

vinext supports App Router, Pages Router, React Server Components, Server Actions, route handlers, streaming SSR, ISR and caching, middleware, static export, standalone Node.js output, the Metadata API, and core next/* imports.

Supported next/* import shims include next/link, next/image, next/navigation, next/server, next/headers, next/cache, and next/og.

Known active compatibility gaps include full cacheComponents behavior, some newer App Router cache semantics, complete build-time image and font optimization, native modules in App Router development, and platform-specific route config such as `runtime` and `preferredRegion`.

## New Project

Start a new vinext project with:

```bash
pnpm create vinext-app@latest my-app
```

## Migration

Use the check command to scan for compatibility issues:

```bash
npx vinext check
```

Then initialize vinext alongside the existing Next.js setup:

```bash
npx vinext init
```

The migration is described as non-destructive: the existing Next.js setup keeps working alongside vinext.

## Deployment

Deploy to Cloudflare Workers with:

```bash
npx @vinext/cloudflare deploy
```

For first-time local setup:

```bash
wrangler login
```

For CI, configure `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID`, or add `account_id` to `wrangler.jsonc`.

Cloudflare bindings can be accessed with:

```ts
import { env } from "cloudflare:workers"
```

## Traffic-Aware Pre-Rendering

vinext includes experimental Traffic-aware Pre-Rendering. It can query Cloudflare zone analytics, pre-render the pages that receive traffic, and cache them to KV. Other pages fall back to on-demand SSR and can be cached through ISR.

```bash
npx @vinext/cloudflare deploy --experimental-tpr
```

## Live Examples

- [App Router Playground](https://app-router-playground.vinext.workers.dev)
- [Hacker News Clone](https://h4cker.app)
- [Nextra Docs](https://nextra-docs-template.vinext.workers.dev)
- [App Router Minimal](https://app-router-cloudflare.vinext.workers.dev)
- [Pages Router Minimal](https://pages-router-cloudflare.vinext.workers.dev)
- [RealWorld API](https://realworld-api-rest.vinext.workers.dev/)
- [Benchmarks Dashboard](https://vinext-web.vinext.workers.dev/benchmarks)
- [App Router + Nitro](https://github.com/cloudflare/vinext/tree/main/examples/app-router-nitro)
- [MarkCut](https://markcut.com)

## Official Links

- [Homepage](https://vinext.io/)
- [GitHub](https://github.com/cloudflare/vinext)
- [Announcement](https://blog.cloudflare.com/vinext/)
- [Benchmarks](https://vinext-web.vinext.workers.dev/benchmarks)
- [Full AI context](https://vinext.io/llms-full.txt)
- [Structured profile](https://vinext.io/api/profile.json)

## Status

vinext is experimental software under active development, built by Cloudflare. It is not affiliated with Vercel or the Next.js team.
