Custom branch preview gets overwritten

I have set up a custom domain and linked it to a custom branch. When I push changes to this branch, it will build a preview as expected. But if then somebody submits a PR to the main branch, which generates a new preview of its own, the preview based on the custom branch will seemingly get overwritten and no longer show the latest changes from the custom branch.

Why is this? Or rather, what am I doing wrong? I would like to use the custom preview branch as a permanent staging area — it should be separate from and in no way affected by what happens in the main branch or other previews.

How can I achieve that?

All best,
Toma

Hi, @ttasovac! Welcome to the Vercel Community :smile:

When you assign a custom domain to a specific branch in Vercel, it should create a stable environment for that branch. This means the custom domain will always point to the latest deployment of the specified branch, and it should not be affected by deployments from other branches or pull requests.

The behavior you’re experiencing, where your custom branch preview seems to be overwritten by a PR to the main branch, is not the expected behavior. Could you try the following?

  1. Go to your project settings in the Vercel dashboard.
  2. Navigate to the “Domains” section.
  3. Add your custom domain (e.g., staging.yourdomain.com).
  4. In the “Git Branch” field, enter the name of your staging branch.

This should set your custom domain to point to the latest deployment of your specified branch, regardless of activity on other branches or pull requests.

Let us know how you get on!