Skip to content

How do I use a Cloudflare domain with Vercel?

If your domain is using Cloudflare's Nameservers and you plan to use it as a custom domains on your project, you may need some minor steps to ensure the domain will work correctly.

Without Proxy (DNS only)

Representation of a domain without the Cloudflare proxy enabled. Requests are served from the closest Vercel edge.

In this method, you need to insert a CNAME record with the value cname.vercel-dns.com. Alternatively, you can use the A record 76.76.21.21. The cloud image should be grayed out with the "Proxy status" set to "DNS only".

CNAME and A records in the Cloudflare dashboard that are not using the Cloudflare proxy.

Following the instructions above will guarantee the speed and reliability of your domain since the DNS resolution will go directly to Vercel without an intermediary.

With Proxy

A Cloudflare proxy works as an intermediary between your domain and Vercel, which is the hosting provider.

Representation of a domain with the Cloudflare proxy enabled. Requests are served from the Cloudflare edge network, which will attempt to retrieve content from the Vercel edge.

To configure a Cloudflare-proxied domain on Vercel, you need to follow these steps:

  • Insert a CNAME record with the value cname.vercel-dns.com (recommended) or an A record with the value 76.76.21.21.
  • Go to SSL/TLS and then Overview in the Cloudflare dashboard, and enable Full to ensure the traffic is always encrypted between Cloudflare and Vercel. You can check the Cloudflare documentation for more information about Encryption modes.

Representation of a domain with the Cloudflare proxy enabled. Requests are served from the Cloudflare edge network, which will attempt to retrieve content from the Vercel edge.

Following the steps above should result in a fully functional website. If you are an advanced Cloudflare user and you are customizing Cloudflare's cache behavior, then it is recommended that you only use the Cloudflare CDN on a Vercel deployment for immutable assets, such as images and CSS/JS files. If the application's pages are cached, it can introduce breakage due to the following behavior: when new deployments are created, the Vercel platform is unable to purge the content cached on Cloudflare. If your visitors load a cached /index.html requiring /static/script-abc.js, but this file is missing both in the new deployment and the Cloudflare CDN, then the website will fail to load the required JS asset and not work properly. Therefore, turning off the Cloudflare CDN for pages is recommended to avoid any unexpected problems.

Note:

Vercel cannot offer Cloudflare-specific support. If you are facing difficulties with your Cloudflare managed domain, please reach out to Cloudflare support.

Couldn't find the guide you need?