Moving botlane.io to Cloudflare Workers
This site is a Next.js app. Here is what it took to run it on Cloudflare Workers, and the few things that didn't move by themselves.
The Botlane studioWritten by the people who build the workThis site is a Next.js app, and until this week it ran on Vercel. It now runs on Cloudflare Workers. Most of the move was configuration; a few parts needed real changes. This is a note on both, for anyone running Next.js who's considering the same.
The adapter
Workers don't run Next.js directly. OpenNext's Cloudflare adapter takes the output of a normal Next.js build and turns it into a Worker, with the static files served as assets alongside it. The Worker's settings live in one file, wrangler.jsonc, kept in the repository with the code.
Where Next.js keeps its cache
Next.js caches pages and data between requests. On Workers that cache needs somewhere to live, so it sits in an R2 bucket bound to the Worker. One thing it holds here: how many Founding Ten places are left, which the site reads from Stripe at most every five minutes rather than on every visit.
The build that needed the internet
The first build failed for a reason that had nothing to do with Cloudflare. The site loaded its two fonts, Inter and JetBrains Mono, through Next.js's Google Fonts loader, which downloads them while the site builds. Where the build couldn't reach Google, it stopped.
We now ship both fonts from npm and load them as local files: same fonts, same weights, and a build that no longer depends on another service being reachable.
A build shouldn't depend on another service being reachable.
Moving the domain without a gap
The new Worker ran on its own workers.dev address first, so we could check it before anyone else saw it. Only then did botlane.io and www.botlane.io move over, as custom domains on the Worker.
After that, the workers.dev address was a second public copy of the site, outside any rules set on the domain. We switched it off in wrangler.jsonc rather than in the dashboard, because a setting changed only in the dashboard is undone by the next deploy.
What we'd pass on
- Nothing in a build should need a third party to be up. Fonts, data, anything: keep it in the repository or fetch it at run time.
- Check the new home on its own address before moving the domain.
- Make the config file the source of truth. Settings changed by hand drift.