Custom Domain Configuration
Set up custom domains with DNS verification and automatic HTTPS.
EdgeBeginner
Why
Custom domains build brand trust and enable root domain serving without managing certificates. Cloudflare's edge network spans 330+ cities with sub-50ms p95 latency globally.
Edge functions reduce TTFB by 60-80% compared to origin servers, and Akamai reports 40% of enterprises now use edge compute in 2024.
When
Any production deployment needing branded URLs. Avoid edge functions for stateful logic requiring database writes — edge runtimes have no persistent connection pool.
Skip if you need long-running tasks (>30s) or heavy CPU computation.
How
# Vercel custom domain via CLI
vercel domains add example.com
vercel domains add www.example.com
# Or in vercel.json
{
"domains": ["example.com", "www.example.com"]
}
# DNS configuration (add to your DNS provider)
# A record: example.com -> 76.76.21.21
# CNAME record: www.example.com -> cname.vercel-dns.com
4. Verify deployment — curl -I https://your-app.example.com
5. Monitor logs — check for errors in first 5 minutes
6. Rollback if needed — revert to previous version
Example
// config — deploy-custom-domain
const config = require("./config");
# Cloudflare DNS for Vercel
Type: CNAME
Name: @
Target: cname.vercel-dns.com
Proxy: Proxied (orange cloud)
# Verify domain
vercel domains inspect example.com
Common Problems
- ⚠DNS not propagating — wait 24-48h or check with dig
- ⚠WWW redirect not working — configure redirects in vercel.json
- ⚠Configuration drift between environments — use infrastructure-as-code (Terraform/Pulumi) to keep dev/staging/prod identical
Best Practices
- ✓Use apex domain — modern DNS supports CNAME flattening
- ✓Set up www redirect — avoid duplicate content
- ✓Set up health checks and graceful shutdown — handle SIGTERM to drain in-flight requests before exit