Projects Blog

Deploying Git Branches as Porkbun Subdomains on Vercel

How to deploy Git Branches as Porkbun Subdomains on Vercel

Sometimes, we want to deploy a subdomain for our website from a specific Git branch.

This subdomains can be used for multiple purposes:

In certain scenarios from these examples, we might not be using the same Git repository, so this branch approach has no sense there. However, in instances like testing, implementing branches becomes a straightforward and practical solution.

For this example, we are going to deploy a subdomain named subdomain, from a dedicated subdomain Git branch.

Let’s walk through the straightforward steps:

Vercel setup

Navigate to your Vercel dashboard, locate your project and select it.

Vercel dashboard

Access Domains. You can either go through Settings or directly click the Domains button in the header.

In the text input, write the desired subdomain and click on Add.

Vercel domains landing page

Click Edit.

Vercel domain entry

Enter the Git branch name and save:

Vercel domain edit page

You will encounter a Invalid configuration error, and immediately below a table with the CNAME record:

Vercel domain entry with error

Don’t close this tab, you will need this value for the next step.

Porkbun setup

Visit the Domain management dashboard or select Domain management from the account dropdown.

Porkbun account dropdown

Locate your domain and click DNS.

Porkbun user domain

Add your subdomain name (beta, shop, admin, etc.) and paste the Vercel CNAME value.

Porkbun domain DNS configuration

Click on Addto finalize the setup in Porkbun.

Back to Vercel

In the Domains section, the domain state should now display Valid configuration. Verify that the branch has been correctly assigned.

Vercel domain entry without errors

Now, the setup is complete! Just wait a few minutes for DNS propagation.


Congratulations! You’ve successfully set up a process for deploying subdomains from specific Git branches using Vercel and Porkbun.

By leveraging subdomains and Git branches, you gain greater control over deployments, maximizing efficiency in your development cycle while simplifying experimentation and iteration.

Happy coding! 🚀