How to deploy Git Branches as Porkbun Subdomains on Vercel"undefined" anchor link
Sometimes, we want to deploy a subdomain for our website from a specific Git branch.
This subdomains can be used for multiple purposes:
- Localization:
es.yoursite.com
,en.yoursite.com
, etc. is a common subdomain pattern used for serving specific content for regions or languages. - API Services: a subdomain such as
api.yoursite.com
is frequently used to separate the endpoints from the main website. - Customer support: when we want to separate the customer services in a
support.yoursite.com
orhelp.yoursite.com
subdomain. - Testing and development:
test.yoursite.com
ordev.yoursite.com
are commonly used for testing or staging in a isolated production environment. - Mobile Version: while you might have encountered the common practice of using
m.yoursite.com
for mobile versions of websites, it’s important to note that this approach is outdated and best avoided.
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"undefined" anchor link
Navigate to your Vercel dashboard, locate your project and select it.

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
.

Click Edit
.

Enter the Git branch name and save:

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

Don’t close this tab, you will need this value for the next step.
Porkbun setup"undefined" anchor link
Visit the Domain management
dashboard or select Domain management
from the account dropdown.

Locate your domain and click DNS
.

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

Click on Add
to finalize the setup in Porkbun.
Back to Vercel"undefined" anchor link
In the Domains
section, the domain state should now display Valid configuration. Verify that the branch has been correctly assigned.

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! 🚀