Typically when building Single Page Applications or simple websites for people or small businesses, I default to using NextJS as well as Vercel simply because its comfortable and easy to set up. This is a small guide based on my experience with deployment on custom domains as well as other subdomains.
Deployment
- Go to and add a new project
- Configure
Vercel
with your Github account - Go to your GitHub Account Settings
- Under
Integrations
, click onApplications
- Under
Vercel
clickConfigure
- Give it access to the specific repository that contains your project code
- Head back to Vercel and complete the deployment from the admin UI
If you are using React frameworks, it is advisable to run npm run build
to catch any errors before deployment
- You should now have a link that you can access your app, e.g.
your-app.vercel.app
Setting up a custom domain
- Find your desired domain name from , or any other domain name registrar
- Head back to Vercel and add the new Domain
- At the
Domains
tab, we can tap on theNAMESERVERS
tab and copy these name servers for the next step - Log into your Namecheap admin console and click on
Manage
for your recently purchased domain name
- Find the
NAMESERVERS
section and we will now populate theCustom DNS
with Vercel's own name servers
These name servers are typically ns1.vercel-dns.com
and ns2.vercel-dns.com
- After clicking on the green checkmark, you have successfully set up the custom domain to route to your site!
A bit about DNS records
There may be scenarios where you would like to put your site under an existing domain that has been purchased. In this case it is important to figure out what DNS records are, particularly A
and CNAME
records.
DNS stands for Domain Name System, which helps to map human readable links like jontay999.com
to a computer readable IP address, e.g. 1.2.3.4
. This mapping is known as a DNS record which are stored on special DNS servers, the main examples of records
A
record: associates a domain name to an IP address. For example, If I wantjontay999.com
to point to1.2.3.4
I will add anA
record
jontay999.com A 1.2.3.4
CNAME
record (canonical name): associates an alias (subdomain) to the canonical (main) domain name. In other words it maps a human readable name to another human readable name. For example, if I own the sitejontay999.com
and I have developed a bunch of games which are deployed on a different host provider. I want to host the games at a new subdomaingames.jontay999.com
, so I will use a CNAME record in this fashion
games CNAME jontay999.com.
The "Name" field is set to games, because the target subdomain is games.jontay999.com
and the "Value" field is set to "jontay999.com" with a period at the end, indicating the canonical domain name
By creating this CNAME record, when someone tries to access games.jontay999.com
, the DNS server will look up the CNAME record and find the canonical domain name "jontay999.com." It will then redirect the request to the IP address associated with "jontay999.com," which is the server where my games are actually hosted
Essentially, the CNAME record acts as an alias or a pointer, allowing the subdomain "games.jontay999.com" to inherit the IP address of the canonical domain "jontay999.com." This way, visitors accessing "games.jontay999.com" will be directed to the appropriate server.
Use Case
Recently, I developed a site for a company but they had trouble accessing it from their company firewall. In the process of trying to find the website IP to whitelist, I realised that Vercel uses Dynamic IP addresses to ensure maximum scalability across different regions (read more ). Sometimes, firewalls block sites that use dynamic IP addresses which makes maintaining robust whitelists and blacklists challenging, among a host of other reasons. To resolve this, we decided to move the site into a company subdomain.
In order to resolve this on Vercel
, we have to find the canonical name server for Vercel which is cname.vercel-dns.com
(this can be found on the Domains
tab). After agreeing on the subdomain, I added this record on Vercel and the company DNS config.
mysite.company-subdomain.com CNAME cname.vercel-dns.com.
Note the trailing period for the canonical name server
In order for it to be fully updated, some time may have to elapse before DNS propagation is completed, but that's it!