Custom Domains and HTTPS

Connect your own domain, configure DNS, and understand Vercel's automatic HTTPS.

🎯 Introduction

A URL such as xxx.vercel.app works, but it can be hard to remember and less suitable for a finished product. In this article, you will connect a domain you have purchased to your Vercel project and learn why you do not need to manage HTTPS certificates yourself.


🧱 Why Use a Custom Domain?

The default domain has two clear drawbacks:

  • It looks less professional: vercel-demo-a1b2c3.vercel.app is long and hard to remember.
  • It is tied to the platform: Its platform suffix makes it less suitable for a finished product.

Your own domain, such as myblog.com, is like a shop sign: memorable, professional, and part of your brand. Purchase one from a domain registrar, such as Alibaba Cloud, Tencent Cloud, or Cloudflare. Annual costs are generally a few to a few dozen yuan.


🛠 Step 1: Add the Domain in Vercel

Suppose you have purchased myblog.com:

Both Vercel and your registrar may update their dashboards, so labels and navigation may differ. The workflow remains the same: add the domain in Vercel → configure DNS at your registrar as instructed → wait for the changes to take effect. Follow the current instructions in both dashboards.
  1. Open your project → Settings → Domains.
  2. Enter myblog.com and click Add.
  3. Vercel reports that the domain is not configured correctly yet and shows the required DNS records.

Add www.myblog.com too. Vercel redirects one to the other so visitors can use either address.


🧱 Step 2: Configure DNS

Open your registrar's DNS management page and add the records Vercel specifies. Two record types serve different purposes:

Record typeHostValueUsed for
A@76.76.21.21Apex domain myblog.com
CNAMEwwwcname.vercel-dns.comSubdomain www.myblog.com

The rule is simple: use an A record to point the apex domain to Vercel's IP address, and a CNAME record to point a subdomain to Vercel's hostname.

DNS changes take time, typically a few minutes but sometimes up to 24 hours. Verification may fail immediately after configuration. Wait a little and refresh.

🔒 Automatic HTTPS

Once DNS verification succeeds, Vercel automatically obtains and deploys an SSL certificate for your domain. Your site supports secure https:// access, indicated by the browser's security icon.

Vercel also renews the certificate automatically before it expires. Compared with manually obtaining certificates, configuring Nginx, and scheduling renewals on a traditional server, this saves considerable work.


💡 Change the Primary Domain

A project can have multiple domains. Under Settings → Domains, choose a primary domain. Other domains, including the original .vercel.app address, redirect with HTTP 301 to the primary domain so visitors and search engines use one address.


❓ Knowledge Check

Q1: Can I follow this article without buying a domain?

Yes. Read through the workflow first. The default .vercel.app domain works for the rest of the course. Return to this exercise when you need a domain for a finished project.

Q2: What is the difference between A and CNAME records?

An A record points directly to an IP address. A CNAME points to another hostname, which resolves to an IP address. Vercel provides an IP address for apex domains, while CNAME records offer more flexibility for subdomains.

Q3: What if the browser reports a certificate error?

DNS may have just propagated while certificate issuance is still in progress. Wait a few minutes and refresh. If the issue persists, check for incorrect or conflicting DNS records.

Q4: What should I consider for a domain registered in mainland China?

Vercel's servers are overseas, so access from mainland China may be slow. Sites targeting mainland Chinese users with mainland servers or CDNs also involve ICP filing requirements. You can focus on learning for now and evaluate these requirements before commercial use.


🧪 Practice

  1. (Optional) Buy an inexpensive domain from a registrar.
  2. Connect it to vercel-demo using the steps above, configure the A record, and observe HTTPS becoming available automatically.

🎉 You now know how to connect a custom domain! Next, we will use vercel.json to fix the common SPA issue where refreshing a route returns 404.