Moving to Cloudflare Workers
The storefront left its old host today. What moved, what deliberately didn't, and the one thing that sent us back for forty minutes.
Engineering3 min read
Today ninjabuy.com moved hosts. The storefront and the docs used to run as a Next.js app on Vercel. They now run on Cloudflare Workers, built with Vinext, a Vite-based implementation of the Next.js APIs. Our DNS and file storage were already on Cloudflare, so the site now sits in the same place as everything around it.
What did not move
The backend stayed exactly where it was. Accounts, carts, orders and payments live in Convex, behind the same address as before, and the browser talks to it directly. Payment providers send their notifications straight to the backend too, so no payment passed through the move at all. That kept the change small: we swapped the thing that draws the pages, not the thing that keeps the records.
Rendering, decided once
Rather than port every page as it was, we made one rule. Most pages ship a static shell and fill in your own data in the browser, so a request does little work on the server. Pages that people find through search engines, like product pages, the docs and the shipping calculator, are still rendered on the server.
The docs went further. Their Markdown versions and their search index are built once at deploy time and served as plain files, and docs search runs in your browser from that prebuilt index.
The switch, and the switch back
www.ninjabuy.com moved at 11:57 UTC, with the bare domain and docs.ninjabuy.com following half an hour later. At 15:45 UTC we moved www back. The docs pages had lost their layout: no sidebar, and a phone layout on a desktop screen.
The HTML was fine. The stylesheet was missing most of the classes the docs layout uses. The docs library declares those classes for Tailwind to pick up, and in our Vite build Tailwind skipped them, so only 50 of 229 made it into the CSS. Telling Tailwind to also scan the library's built files fixed it. We checked the fix on a test host, and www was back on Workers at 16:25 UTC.
The old host stayed as a fallback until the next day, when we switched it off.
