Deploying Next.js apps to Vercel
This post covers the main notes for deploying to Vercel and domain setup.
Prerequisites
- Next.js app bootstrapped
Deployment
Add a new project, import the Git repository, choose Next.js as the framework preset, set up environment variables, and trigger the deployment.
The deployed project will be available at <PROJECT_NAME>.vercel.app
or <PROJECT_NAME>-<SUFFIX>.vercel.app
URL.
The deployment happens every time new changes are pushed to the production branch.
Preview will be available when changes are pushed to a branch other than the production one.
DNS setup
A purchased domain is needed. You can buy it at Namecheap website.
Add a domain at the Project settings → Domains page.
Go to Account → Dashboard → Manage → Advanced DNS page for the purchased domain on the Namecheap website. Create two records
A
record with@
host to point to Vercel server IP address with the specified value (76.76.21.21
)CNAME
record withwww
host and specified value (cname.vercel-dns.com
)
It might take some time for the changes to apply.
Boilerplate
Here is the link to the boilerplate I use for the development.