Back to blog

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

SymptomCauseFix
Middleware fails at buildproxy.ts uses the Node runtimeUse middleware.ts (Edge)
new Function errorWorkers block dynamic evalRender at build time

Deploy is a single pnpm run deploy. CI can automate it with the same command.