Next.js 15.5 × Cloudflare Workers

Every request
lands close.

A production-shaped Next.js starter that compiles into a single Cloudflare Worker. Server rendering, typed API routes and static assets — all answered by the edge city nearest to the visitor.

App Router · TypeScript · Tailwind 4 · OpenNext

01 / LIVE EDGE

Ask the Worker where you are.

This panel is server-rendered on the first hop, then refreshed by a route handler running on the same Worker. Nothing is stored.

Nearest colo

CMH

Country
US
Runtime
Cloudflare Workers
Client
216.73.•••.•••
Seen at
05:34:44 UTC
Round trip
not measured
CF-Ray
a648719a68c8c125

Values come from Cloudflare request headers: cf-ray, cf-ipcountry and cf-connecting-ip. Outside Cloudflare they fall back to LOCAL.

02 / REQUEST PATH

One hop from browser to render.

There is no origin server behind this page. The Worker is the server, and it runs in the same location that terminates TLS.

  1. 01

    Request

    A browser asks for /api/edge. DNS resolves to the closest Cloudflare location.

  2. 02

    Edge PoP

    TLS terminates at the colo. Cloudflare annotates the request with cf-ray, country and client IP.

  3. 03

    Worker

    The Next.js server bundle runs inside workerd. Route handlers and React Server Components execute here.

  4. 04

    Response

    JSON or streamed HTML travels back from the same city. No origin server sits in the middle.

03 / WHAT'S INSIDE

Small stack. Real primitives.

A deliberately small set of primitives, wired the way the platform expects them.

A

Streaming SSR

React Server Components render per request inside the Worker. Static shells are served by Workers Static Assets.

app/page.tsx
B

Real edge headers

The route handler reads Cloudflare's request headers and returns a typed snapshot of colo, country and client.

app/api/edge/route.ts
C

Reproducible deploys

OpenNext turns next build into a Worker bundle; Wrangler uploads the script and its assets in one command.

npm run deploy

04 / SHIP IT

Build here. Serve everywhere.

Local development runs on Node. Production runs on workerd. The same source, two runtimes.

$ npm install

$ npm run dev # localhost:3000

$ npm run deploy # build + upload

↳ cloudflareworkers-me.workers.dev

Deploys need a Cloudflare API token with Workers Scripts: Edit. Export CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID, or run wrangler login on the machine that ships.

The Worker name and compatibility date live in wrangler.jsonc. The adapter entry point is open-next.config.ts.