I had a perfectly normal Next.js app, and I wanted it running on Cloudflare Workers. That's it. That was the whole plan.
Then I found out there are two ways to do it in 2026, and because I can't leave well enough alone, I tried both.
Road one is vinext, a Vite-native framework that's compatible with Next. Road two is OpenNext (specifically @opennextjs/cloudflare), which takes Next's own server output and tucks it inside a Worker.
Spoiler: both work. And both are "free" as far as the platform bill goes. But "free" is doing a lot of heavy lifting in that sentence, because what you actually pay with is:
- Config you have to write and keep alive
- Compatibility gaps you have to patch yourself
- Build time and Worker size
- The upgrade treadmill you quietly sign up for
I found all four the hard way. Here's the story, with real code from a production-ish app: Next 16, Clerk for auth, Prisma on Neon, server actions, and next/image.
The short version (for the skimmers)
- The platform bill is the same. Both run on Workers, so requests, CPU time, subrequests and egress cost the same (Workers pricing).
- The real bill is your time. On vinext, Clerk needed three separate workarounds. On OpenNext, it needed none.
- vinext gives you faster builds, a smaller Worker, and a dev loop that runs in workerd.
- OpenNext gives you real Next.js, but only on the Next versions it supports.
- If you're staying on Cloudflare for the long haul, I'd take OpenNext. The cheapest adapter is the one whose problems someone else already fixed.
The app (boring on purpose)
The app is unremarkable in the best way: the App Router, "use server" actions, revalidate, next/image, Clerk for login, and Prisma over Neon. There's no framework-specific code anywhere: no vinext imports and no @opennextjs imports in app/.
That's the good news. The app code is portable. Everything I'm about to complain about (or praise) lives in the adapter.
| vinext | OpenNext Cloudflare | |
|---|---|---|
| What runs | A Next-compatible reimplementation on Vite/RSC | Your real next build output |
| Config files | vite.config.ts + cloudflare.config.ts + wrangler.jsonc | next.config.ts + open-next.config.ts + wrangler.jsonc |
| Dev server | vite dev (edge-accurate) | next dev (Node) + wrangler bindings |
| Next version | Loose | Pinned (`next >=15.5.29 <16 \ |
Step 1: The config pile
First up: what do you actually have to write before anything runs?
The vinext way
You wire up the Cloudflare Vite plugin next to vinext, then describe your Worker in a TypeScript config.
{% raw %}
// vite.config.ts import { defineConfig } from "vite"; import vinext from "vinext"; import { cloudflare } from "@cloudflare/vite-plugin"; import { imagesOptimizer } from "@vinext/cloudflare/images/images-optimizer"; export default defineConfig({ plugins: [ vinext({ images: { optimizer: imagesOptimizer() } }), cloudflare({ viteEnvironment: { name: "rsc", childEnvironments: ["ssr"] } }), ], }); // cloudflare.config.ts import { bindings, defineConfig, defineWorker } from "cf/config"; export default defineConfig({ worker: defineWorker({ name: "my-app", entrypoint: "vinext/server/fetch-handler", compatibilityDate: "2026-11-20", env: { DATABASE_URL: bindings.secret(), CLERK_SECRET_KEY: bindings.secret(), NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: bindings.text("pk_test_..."), }, }), }); The bindings get typed from that config (.cloudflare/types/index.d.ts), and your app reads them as plain process.env:
const connectionString = `${process.env.DATABASE_URL}`; // just works The OpenNext way
Here the config lives in your Next config plus a wrangler file. You also pick a cache, like an R2-backed incremental cache, and turn on nodejs_compat.
// next.config.ts import type { NextConfig } from "next"; import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare"; initOpenNextCloudflareForDev(); // makes bindings available in `next dev` const nextConfig: NextConfig = { /* your normal Next config */ }; export default nextConfig; // open-next.config.ts import { defineCloudflareConfig } from "@opennextjs/cloudflare"; import r2IncrementalCache from "@opennextjs/cloudflare/overrides/incremental-cache/r2-incremental-cache"; export default defineCloudflareConfig({ incrementalCache: r2IncrementalCache }); // wrangler.jsonc { "main": ".opennextjs/cloudflare-worker.js", "compatibility_date": "2026-11-20", "compatibility_flags": ["nodejs_compat"], "assets": { "directory": ".opennextjs/assets" }, "vars": { "NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY": "pk_test_..." } } Bindings come from wrangler, and your app reads them through the Cloudflare context:
import { getCloudflareContext } from "@opennextjs/cloudflare"; const { env } = getCloudflareContext(); const connectionString = env.DATABASE_URL; My take: it's about the same amount of config either way. vinext puts it in TypeScript with generated types and process.env everywhere. OpenNext keeps it all in wrangler.jsonc as one source of truth, but you end up calling getCloudflareContext() in your data layer.
Step 2: Where does your code run while you're building it?
This is where the two feel totally different.
vinext's vite dev runs your app inside workerd, so your local dev loop is the real deployment runtime. I loved that. The require gotchas, the missing Node APIs and the Workers quirks all show up right at localhost, instead of waiting for you in a preview deploy.
OpenNext's dev server is plain next dev in Node, with initOpenNextCloudflareForDev() slipping the bindings in. It's fast, it's familiar, and everything just works. But now your app is running on a different runtime than production, and the differences show up later, at opennextjs-cloudflare preview time.
You'll make this trade over and over:
- vinext: painful at dev time, predictable at deploy time.
- OpenNext: smooth at dev time, surprises at deploy time.
Step 3: The Clerk saga (where my afternoon went)
Okay, grab a coffee. This is the part where the money goes.
My very first vite dev boot put this in the browser console:
@clerk/nextjs: SignedOut can only be used within the <ClerkProvider /> component. Great, except ClerkProvider was sitting right there in app/layout.tsx. The error was lying to me. What was really happening: Vite's dependency optimizer had split Clerk's React context into two separate module instances.
SignedOut$1 (…/.vite/deps/@clerk_nextjs.js) ClerkContextProvider (…/@clerk/clerk-react/dist/index.mjs) Vite actually tried to warn me, right above the error: client component dependency is inconsistently optimized. It's recommended to add the dependency to optimizeDeps.exclude.
Workaround #1: keep Clerk away from the optimizer
// vite.config.ts (vinext) environments: { client: { optimizeDeps: { exclude: ["@clerk/nextjs", "@clerk/clerk-react", "@clerk/shared"] }, }, }, Workaround #2: turn off Clerk's keyless check
That fixed it, and then the next error showed up. Clerk's dev-only "keyless" check fires a Next server action on mount, and vinext's browser router answered with:
Browser router state is not initialized The fix is one env var:
NEXT_PUBLIC_CLERK_KEYLESS_DISABLED=1 Workaround #3: the require() boss fight
And then came the real one:
[vinext] Server render error: ReferenceError: require is not defined at currentUser (node_modules/@clerk/nextjs/dist/esm/app-router/server/currentUser.js:5) at Home (app/page.tsx:29:22) Here's what's going on. The ESM build of @clerk/nextjs contains literal require() calls: require("server-only") inside auth() and currentUser(), and require("next/navigation") inside its routing hooks. Next's Node server has a require global, so it works there. workerd doesn't have one, and vinext deliberately skips rewriting require() inside node_modules ESM.
This one has no config knob. It needs an actual plugin:
// vite.config.ts (vinext) — the tax import { defineConfig, type Plugin } from "vite"; function clerkRequireShim(): Plugin { const markers = /require\(\s*["'](?:server-only|client-only)["']\s*\)\s*;?/g; const navigation = /require\(\s*["']next\/navigation["']\s*\)/g; return { name: "clerk-edgesafe-require", enforce: "pre", transform(code, id) { if (!/[\\/]@clerk[\\/]/.test(id)) return; let out = code.replace(markers, ""); if (navigation.test(out)) { navigation.lastIndex = 0; out = `import * as __vinext_next_navigation from "next/navigation";\n` + out.replace(navigation, "__vinext_next_navigation"); } return out === code ? undefined : { code: out, map: null }; }, }; } It works. I checked it on /, /sign-in, /sign-up, server actions and Prisma queries. But look at what I'd just bought myself:
- Three workarounds for one library
- One of them a source transform that will quietly rot the day Clerk changes its build output
- A debugging session that ate a couple of hours of profiler and stack-trace digging
On OpenNext, none of this exists. It runs your real next build output on Next's own server, so require is provided, contexts get bundled once, and server actions are Next's own. The equivalent cost? Zero lines.
That's the real headline of this whole story: the adapter you don't have to write is the cheapest one.
Step 4: How big is the thing, and how fast does it wake up?
Both adapters land on the same Workers runtime, so request and CPU billing is identical. The difference is the package you ship.
- OpenNext bundles Next's server and its runtime into the Worker. Expect a multi-megabyte bundle and slower cold starts, plus a real
next buildin CI. - vinext produces a Vite/RSC bundle, which is smaller and builds much faster (seconds, not a minute-plus).
Don't take my word for it. Measure it on your own app:
# OpenNext: build, then look at the Worker size npx opennextjs-cloudflare build npx wrangler deploy --dry-run --outdir=.worker-out # vinext: build, then the same check npx vite build npx wrangler deploy --dry-run --outdir=.worker-out Think of bundle size as a cold-start tax. For a content site with steady traffic, who cares. For a low-traffic app where every request is a cold start, your users will feel it.
Step 5: Okay, but what does it actually cost?
Straight answer: the platform bill is the same. Both are Workers. Requests, CPU time, subrequests and egress are all priced the same way, and neither adapter adds a per-request fee.
So where does the cost land?
| Cost line | vinext | OpenNext |
|---|---|---|
| Platform (Workers) | Identical | Identical |
| CI build time | Low (Vite) | Higher (next build + transform) |
| Cold starts | Lower (smaller bundle) | Higher |
| Your engineering time | Higher: you patch compat gaps | Lower: Next semantics are Next |
| Upgrade risk | Tracks Next loosely | Pinned to supported Next versions |
| Ongoing maintenance | Your workaround code | Adapter upgrades |
If your time is worth $100/hour and my Clerk adventure took two hours, vinext "cost" $200 up front. And every future library with a require() in its ESM build costs more.
Step 6: The upgrade treadmill
This is the one nobody talks about. @opennextjs/cloudflare@1.20.x declares:
"peerDependencies": { "next": ">=15.5.29 <16 || >=16.4.5" } If you're on next@16.0.8, you have to upgrade to >=16.4.5 before OpenNext will even install cleanly. That's a four-minor-version jump on a React 19 app, which is a real risk, not a checkbox.
vinext doesn't pin you like that. Which is exactly why the require() gap lands on your desk instead of the adapter's.
So the trade is honest:
- OpenNext: you upgrade Next on the adapter's schedule, and the adapter fixes compatibility for you.
- vinext: you upgrade Next whenever you want, and you fix compatibility yourself.
The scorecard
| vinext | OpenNext | |
|---|---|---|
| App code changes | None | None |
| Adapter config | ~40 lines TS | ~30 lines JSON/TS |
| Library compat | Patch it yourself (Clerk: 3 fixes) | Handled |
| Dev loop accuracy | workerd, matches prod | Node, diverges |
| Build speed | Fast | Slower |
| Worker size | Smaller | Larger |
| Next version freedom | High | Constrained |
| Long-term maintenance | Yours | Adapter's |
So what would I actually do?
- Shipping Next on Cloudflare for the long haul? Take OpenNext. Pay the Next upgrade once, stop writing workarounds, and let the adapter own compatibility. It's the supported path, and my Clerk afternoon is the proof of why that matters.
- Want the Vite dev loop, or stuck on a Next version OpenNext doesn't support yet? vinext is fine. Just budget for one workaround per "Next-ecosystem library with a weird build output" you adopt, and keep those patches in one file so you can delete them later.
- Either way, try it in a branch. Run
bunx wrangler deploy --dry-run --outdir=.worker-outon both builds, then check/, a server action and a Prisma query underopennextjs-cloudflare preview. That's one afternoon, and it'll answer the question for your app better than any benchmark post.
The takeaway
The adapter with fewer files isn't the cheaper one. The cheapest adapter is the one whose compatibility gaps someone else already fixed.
Want the opposite conclusion? If you need
next/font, ISR and image optimization to behave exactly like Next, OpenNext is the only option that gives you Next's own implementation.
The config snippets come from a real Next 16 / Clerk / Prisma-Neon app. The vinext workarounds are accurate at the time of writing, so check them against your Clerk version before copying.
Btw, I'm Sajal, a Full-Stack JavaScript Developer specializing in React and Next.js.
I help businesses increase conversions and revenue through performance-driven website optimization, focusing on performance, SEO, and user experience.
Looking to get more out of your website? Let's connect.
🌐 Website: https://sajallabs.com
💼 LinkedIn: https://www.linkedin.com/in/ashsajal/


