How I Connect a Custom Domain to Cloudflare Pages
By Usama Kashif - frontend engineer and product builder sharing practical product, UX, and engineering experience.
To connect a custom domain to a Cloudflare Pages project, open the project in the Cloudflare dashboard, go to Custom domains, and choose “Set up a domain”. For an apex domain like example.com the domain has to be a Cloudflare zone with its nameservers pointed at Cloudflare; a subdomain like www.example.com can instead use a CNAME to your .pages.dev address. This is how I do it for my own sites, including this one.
This post covers the Cloudflare Pages and DNS side only. It starts after you own a domain and does not walk through any registrar’s screens; any registrar works once the nameservers or records point where Pages needs them.
What these domains do for me
I build Android apps with Expo and React Native, and each one needs a stable website. Mine live on one domain, so every app has a real, permanent address:
- App pages such as CookThis, ScrollStop, RoadTally and Meni.
- The privacy policy for each app, at paths like /scrollstop/privacy/ and /cookthis/privacy/. A store listing points at that URL, so it needs to keep working, and it needs to stay on the hostname I control.
- Marketing and blog pages, which you are reading now.
Meni also has its own subdomain, meni.usamakashif.me, listed as its website on the Meni page.
The host I actually use: www
My canonical host is https://www.usamakashif.me. The apex usamakashif.me and plain http:// both permanently redirect (301) to it at the Cloudflare level, and the site uses trailing slashes, so a slashless path redirects to the slashed one. Every absolute link I write uses https://www.usamakashif.me/.../.
The reason to pick one canonical host is simple: search engines and store listings should see one address for each page. Which one you choose matters less than choosing and redirecting the other.
Steps in the Cloudflare dashboard
These follow Cloudflare’s custom domains for Pages documentation (checked 29 Nov 2026), which is the source to trust if anything below has changed.
- In the Cloudflare dashboard, go to Workers & Pages and select your Pages project.
- Open Custom domains, choose “Set up a domain”, enter the domain, and continue.
- If it is an apex domain, Cloudflare’s docs say you need to add the site as a Cloudflare zone and set your nameservers to Cloudflare’s. Cloudflare then creates the CNAME for you.
- If it is a subdomain such as
www, the docs say the site does not need to be a Cloudflare zone. You add a CNAME from the subdomain to<your-project>.pages.dev. - Wait for the domain to show as active, then load it over HTTPS.
Both usamakashif.me and mathvsarham.com use Cloudflare nameservers. I checked that with a DNS lookup on 29 November 2026. Nameservers alone do not tell you which registrar a domain was bought from, and I am not making a point about that here.
The mistake that breaks the domain
Cloudflare’s docs warn about one specific thing: manually adding a CNAME to your Pages site without first associating the domain in the Pages project makes the domain fail to resolve, and the docs show a 522 error for it. Add the domain in Pages first and let Cloudflare create or confirm the record, rather than creating the CNAME by hand.
The same page also notes that CAA records can block certificate issuance, so check them if HTTPS does not come up.
Why the hostname matters beyond the website
Once a domain is attached, other things start depending on it: store listings, privacy-policy URLs, email links, auth redirects. I wrote about one case in how I fixed Google’s red warning on Supabase password reset links, where putting links on a domain I control, through a Cloudflare Worker, avoided users being sent to a shared domain that Google flagged. Different problem, same lesson: the address you control is the one you can keep stable.
For more of what I build on this, see my projects and the rest of the blog.
Sources and check dates
Checked on 29 November 2026.
Frequently asked questions
How do I add a custom domain to Cloudflare Pages?
Do I need to move my nameservers to Cloudflare?
Should I use www or the apex domain?
Why does my domain show a 522 error?
Why does a privacy-policy URL need a stable domain?
see food. snap it. cook it.
CookThis turns food photos, ingredients, and cravings into practical, beginner-friendly recipes for a real home kitchen.
More Posts
Is RevenueCat Worth It for a Solo Android Developer (Including from Pakistan)?
Yes, for my shipped Expo Android apps. What RevenueCat costs per its pricing page, what its country table says about Pakistan, and where it may not fit.
How I Use RevenueCat in My Expo Android Apps: Entitlements and a Lifetime Purchase
How I use RevenueCat in shipped Expo Android apps: entitlements, a one-time lifetime unlock with restore, Expo Go vs a development build, and Play testing.