I moved this site from Vercel to Cloudflare in one day, and no visitor or crawler saw an error, a missing page or a changed status code. Three things made that possible. Every DNS record was copied to Cloudflare as DNS-only before the nameservers changed. A script compared all 2,873 URLs between the two hosts and had to report zero unexplained differences. And each hostname was switched by editing its existing record in place, so there was never a gap between the old answer and the new one. Cloudflare's free plan now serves the static export, the analytics endpoint, email and DNS, for $0 a month.
Why leave Vercel at all?#
Lighthouse was not the reason. PageSpeed mobile was already 98 to 100, and the same HTML scores the same anywhere. Four other things were:
- The Hobby plan pauses a project at 1M CDN requests a month. On 18 November the account sat at about 814K and grew about 25K a day, so it would cross around the 28th. A paused project answers
503 DEPLOYMENT_PAUSED, and Google drops URLs that keep returning server errors. About 2,600 bank pages had been indexed that month. - Hobby is for personal, non-commercial use, and this site markets three apps.
- Cloudflare doesn't charge for static assets: its docs say requests to static assets on Workers are free and unlimited.
- Much of the audience is in the Gulf, and Vercel has no Middle East region. Cloudflare has data centers in Riyadh, Jeddah, Dammam, Baghdad, Manama and Dubai. In my measurements, cached TTFB from Tel Aviv went from 354 ms to 28 ms, and from Baku from 360 ms to 34 ms. Europe and the US got 20 to 100 ms slower, which I accepted.
What does "zero downtime" have to cover?#
I wrote the goal down before touching anything, and it covers far more than the home page staying up:
- No visitor or crawler sees an error, a missing page or a different status code, during or after the move.
- Every URL answers the same status, final URL, canonical, title, robots tag and JSON-LD on Cloudflare as on Vercel, proven by a script before DNS points anywhere new.
- Every step can be rolled back, quickly, until Vercel is retired.
- No feature is lost: feeds, OG images, the Spotify widget, chat, analytics events, app deep links.
The last one matters because the site was not a plain static site. It used Next.js rewrites to serve pages from three other repositories, an API route for analytics, and Vercel's image optimizer.
How do you turn a Vercel Next.js app into a static site?#
With output: 'export', plus a replacement for each thing Vercel did at request time:
- Rewrites from other repos became a build step that copies those pages into the export.
- The analytics API route moved into a small Worker that runs only on the paths listed in
run_worker_first. Everything else is served straight from static assets and never wakes the Worker. next/imagegot a custom loader that points at Cloudflare's/cdn-cgi/image/transformations.- Headers and redirects are generated as
_headersand_redirectsfrom one table, so the two files can't drift apart.
Before any of this I tagged the last Vercel commit vercel-final and froze Vercel. Git builds were switched off, and a guard made any build on Vercel fail. A failed build never replaces production, so Vercel kept serving the exact deploy I would roll back to.
How do you move DNS without breaking anything?#
Copy every record first, and change nothing about where traffic goes. I added the zone to Cloudflare and recreated every record exactly: the apex, www, three app subdomains, a GitHub Pages subdomain, the verification TXT records. Every one was DNS-only (grey cloud), so Cloudflare answered with the same Vercel targets the old nameservers gave.
A script queried the old and new nameservers for every name and compared the answers. It also checked that there was no DS record at the registrar, because DNSSEC with a stale DS takes a domain offline. Only then did I switch the nameservers.
During propagation, some resolvers asked the old nameservers and some asked Cloudflare. Both said "Vercel", so both were right. I set TTL 300 on every record, because that makes the cutover rollback a matter of minutes.
How did I prove the two hosts were identical?#
With a parity gate. Cloudflare served the new build on a staging hostname with X-Robots-Tag: noindex, and a script fetched every URL from production (Vercel) and from staging. That meant every sitemap URL, every redirect source, every page copied from the app repos, and every app-subdomain path. For each URL it compared:
status, final URL, canonical, title, robots, hreflang,
JSON-LD, content-type, and the security headersThe first sample showed 256 differences. Grouping them by field turned them into 6 decisions. Most were intended, such as a stricter HSTS header or security.txt now being served. Two were real bugs, and both were fixed. The full run covered 2,873 URLs, and every remaining difference was either intended or a fix on the Cloudflare side.
The gate still missed something. It read HTML and headers, never images, and Image Transformations turned out to be off on the zone. Every /cdn-cgi/image/ URL on staging had been a 404 since the first deploy. I found it because the PageSpeed LCP on /projects was slow. Now check:prod fetches one real image per run. If your migration check reads HTML, make it also fetch one of every asset type the HTML references.
How do you switch a hostname with no gap?#
Edit the record in place. Deleting and recreating it leaves a moment with no answer.
The Worker route www.mohamedgado.com/* already existed while the record was still DNS-only. A route does nothing until the record is proxied, so it sat there inert. The cutover for www was one API call that turned the DNS-only record into a proxied one:
PATCH /zones/:zone/dns_records/:id
{ "proxied": true, "ttl": 1 }From that moment Cloudflare answered, and the Worker route served the request. Anyone with a cached DNS answer still reached Vercel, which was still live and still correct. The script then fetched / from Cloudflare's own resolver answer and asserted the response came from Cloudflare, not from a Vercel ID header. Rollback was the same call with "proxied": false.
I didn't use a Workers Custom Domain for the live hosts. You can't create one while a CNAME exists for that name, and deleting the CNAME first opens exactly the gap I was trying to avoid.
The order was www first, then one hour of watching check:prod and the error rate, then the apex, then each app subdomain, one at a time. After every step, check:prod --all passed on all 789 pages, with 0 errors served to visitors and 0 crawler 403s.
What went wrong anyway?#
Nothing visitors saw, but a few things I would check earlier next time:
- Old
/_next/image?url=...links from Vercel live on in RSS readers, shares and image search. They 404'd on Cloudflare. A redirect rule now sends local sources to the original file with a 301. My first version of that rule failed in production while its test passed, because Cloudflare hands query values to rules still percent-encoded and my test decoded them. The rule now wraps the value inurl_decode(). - Hours after the DS record went live, 1.1.1.1 returned SERVFAIL for some queries, while Google and Verisign's analyzer validated the whole chain. Some 1.1.1.1 cache nodes still held the pre-DS answer. Cloudflare's public purge tool cleared it.
- A local
wrangler deployuploads every asset, about 340 MB here, and my connection dropped it three times. Workers Builds builds in Cloudflare instead, triggered by a deploy hook.
What did Cloudflare's free plan give me?#
| What | Before | After |
|---|---|---|
| Hosting cost | Free, but paused at 1M requests | $0, static requests unlimited |
| Gulf TTFB | No regional edge | Edges in KSA, Iraq, Bahrain, UAE |
| DNS | Registrar DNS | Cloudflare DNS with DNSSEC and CAA |
| No mail on the domain | Email Routing, SPF -all, DMARC p=reject, BIMI logo |
|
| Security | HSTS preload | HSTS preload, plus a WAF rule and a rate limit |
| Images | Vercel optimizer | Transformations in AVIF, falling back to the original past the free quota |
Free tiers have limits, so every metered limit lives in one module, with a budget at 90% of it. A health script reports usage against those budgets, and the deploy defers writes before a daily limit is hit.
The PageSpeed score stayed where it was. /projects scored 97 after the cutover, the same as on Vercel.
The short version#
- Freeze the old host on a tagged deploy so rollback is always ready.
- Copy every DNS record as DNS-only and compare both nameservers by script before switching.
- Serve the new build on a noindex staging host and diff every URL. Fetch real images, not only HTML.
- Add routes before they're live, then cut over each hostname with an in-place edit, one at a time.
- Watch the error rate and crawler status codes, then retire the old host.
The site has run only on Cloudflare since 18 November, and the Vercel project is deleted.