Running Next.js on Cloudflare Workers
1 min read
#Next.js#Cloudflare#Infrastructure
Overview
With the @opennextjs/cloudflare adapter you can run a Next.js App Router app
on Cloudflare Workers. Pages + next-on-pages is being deprecated, so for new
projects the Workers setup is the way to go.
Setup
pnpm add @opennextjs/cloudflare
pnpm add -D wrangler
Don't forget to enable the nodejs_compat flag in wrangler.jsonc.
{
"name": "portfolio",
"main": ".open-next/worker.js",
"compatibility_date": "2026-06-01",
"compatibility_flags": ["nodejs_compat"]
}
Gotchas
| Symptom | Cause | Fix |
|---|---|---|
| Middleware fails at build | proxy.ts uses the Node runtime | Use middleware.ts (Edge) |
new Function error | Workers block dynamic eval | Render at build time |
Deploy is a single pnpm run deploy. CI can automate it with the same command.