Next.js frontend onto Cloudflare Workers via @opennextjs/cloudflare

Four commits to get the Next.js frontend shipping to Cloudflare Workers: a `next` version bump to satisfy the peer range, a minimal `wrangler.jsonc`, explicit `cf:build`/`cf:deploy`/`cf:preview` npm scripts, and deletion of `frontend/bun.lock` to stop Cloudflare's auto-detection from picking Bun.

infrastructure

The next bump from 16.0.3 to 16.0.11 is a peer-range fix. @opennextjs/cloudflare requires ~16.0.11 || ^16.1.5; the original pin broke install on the Cloudflare deploy. This is a safe pull regardless of whether you take any other part of this thread.

The wrangler.jsonc is the canonical output of the @opennextjs/cloudflare CLI: worker name "gary," nodejs_compat and global_fetch_strictly_public compatibility flags, an ASSETS binding pointing at .open-next/assets, the WORKER_SELF_REFERENCE service binding (self-referential, required for the OpenNext caching layer), and an IMAGES binding for image optimization. Standard boilerplate; nothing fork-specific beyond the name.

foolish-bandit split cf:build and cf:deploy into separate scripts in frontend/package.json rather than relying on the combined deploy script, and added README documentation explicitly calling out that this is the Workers path, not Pages. The bun.lock removal is the same story as the backend: Cloudflare's framework detector sees a Bun lockfile and provisions Bun, even though this project uses npm. Deleting it fixes the detection.

So what Worth a look if your fork also targets Cloudflare Workers. The `wrangler.jsonc` and `cf:*` scripts are copy-paste-ready after substituting your worker name. Pull the `next` bump unconditionally - it's a peer constraint fix with no behavior change. If your team uses Bun locally, the `bun.lock` deletion will create churn; `package-lock.json` stays intact so npm installs are reproducible.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

6 commits from foolish-bandit/gary, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
97471172 Merge pull request #2 from foolish-bandit/claude/fix-next-cloudflare-compat Zack Brenner 2026-05-07 ↗ GitHub
Upgrade Next.js from 16.0.3 to 16.0.11
8c8dbba6 Merge pull request #3 from foolish-bandit/claude/remove-frontend-bun-lockfile Zack Brenner 2026-05-07 ↗ GitHub
Remove frontend/bun.lock so Cloudflare uses npm
b6dc0e42 Bump next to 16.0.11 for Cloudflare deploy compatibility Claude 2026-05-07 ↗ GitHub
commit body
@opennextjs/cloudflare requires next ~16.0.11 or ^16.1.5; the pin at
16.0.3 broke install on the Cloudflare deploy. Bumping to 16.0.11
satisfies the peer range with the smallest possible version change.
React, React DOM, @opennextjs/cloudflare, and other deps are unchanged
- the lockfile churn beyond the next version bump is just npm
renormalizing dev/devOptional flags and deduping transitive deps.

https://claude.ai/code/session_01McEfVnpbGdMs5TgeTM7P3R
f01df75f Add minimal wrangler.jsonc for Cloudflare deploy Claude 2026-05-07 ↗ GitHub
commit body
After bumping next to satisfy the peer range, the next failure on the
Cloudflare deploy was that opennextjs-cloudflare build couldn't find
a wrangler config. Adding the canonical default the @opennextjs/cloudflare
CLI emits: project name "gary", nodejs_compat + global_fetch_strictly_public
flags, ASSETS binding, the OpenNext self-reference service binding (required
for the OpenNext caching layer per opennext.js.org/cloudflare/caching), and
the IMAGES binding for image optimization.

https://claude.ai/code/session_01McEfVnpbGdMs5TgeTM7P3R
befcd221 Add cf:* scripts and Workers deploy docs Claude 2026-05-07 ↗ GitHub
commit body
The frontend deploys to Cloudflare Workers via @opennextjs/cloudflare,
not Cloudflare Pages. Add explicit cf:build, cf:deploy, cf:preview
scripts so the Cloudflare project's build/deploy commands map directly
to npm scripts (the existing combined preview/deploy/upload scripts
are kept for backward compatibility). Document the Workers deploy
flow in the README so contributors don't reach for the Pages path.

wrangler.jsonc already satisfies the OpenNext-on-Workers requirements
(main: .open-next/worker.js, assets.directory: .open-next/assets,
assets.binding: ASSETS, compatibility_flags includes nodejs_compat).

https://claude.ai/code/session_01McEfVnpbGdMs5TgeTM7P3R
9de83b4a Remove frontend/bun.lock so Cloudflare uses npm Claude 2026-05-07 ↗ GitHub
commit body
Cloudflare's framework auto-detection picks Bun whenever a Bun
lockfile is present, even though the project is npm-managed and
ships with package-lock.json. Removing bun.lock makes the build
agent fall back to npm. package-lock.json is unchanged
(npm install reports "up to date").

https://claude.ai/code/session_01McEfVnpbGdMs5TgeTM7P3R

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-158.md from inside the repo you want the changes in.

⬇ Download capture-thread-158.md