Controlling Branch Deployments and Redirects in Vercel: A Practical Guide
Continuous deployment platforms simplify the release process, but they can easily become noisy when every branch triggers a build. Teams working with multiple development environments often need finer control — building only when specific branches are updated and ignoring the rest.
The Problem
Imagine a development team maintaining three main branches:
main— productiondevelop— staging and QAlocalhost— internal experiments
By default, Vercel automatically builds and checks every branch pushed to the connected Git repository. As a result, even experimental or local branches can consume build minutes and bandwidth unnecessarily.
The Solution: The Ignored Build Step
Vercel provides a configuration mechanism called the Ignored Build Step (or ignoreCommand when declared inside vercel.json).
This command determines whether a new build should occur after a commit.
If the command exits with code 0, the build is skipped; with code 1, it proceeds.
A simple Bash script can enforce selective builds:
#!/usr/bin/env bash
if [ "$VERCEL_GIT_COMMIT_REF" = "develop" ] || [ "$VERCEL_GIT_COMMIT_REF" = "main" ]; then
exit 1 # Build allowed
else
exit 0 # Ignore other branches
fi
Then, reference it in the project’s vercel.json:
{
"ignoreCommand": "bash scripts/ignored-builds.sh"
}
This ensures that Vercel will build and run checks only for develop and main, ignoring branches like localhost.
Managing Redirects in the Same Configuration
Vercel’s configuration also supports custom redirects, which can coexist with the ignore command.
For instance, you can centralize payment routes or API paths:
{
"redirects": [
{ "source": "/pagos/:path*", "destination": "https://payments.example.com/:path*", "statusCode": 301 }
],
"ignoreCommand": "bash scripts/ignored-builds.sh"
}
Redirects are processed in order, and you can use 301 or 302 codes depending on whether the move is permanent or temporary.
Why This Matters
Selective deployment is not only a matter of optimization — it is a safeguard for the production workflow.
Unnecessary builds can lead to inconsistent states, unexpected domain previews, and wasted compute time.
By combining ignoreCommand with explicit redirects, developers can enforce clean and predictable deployment rules directly from the repository.
Conclusion
Managing branch-specific builds in Vercel gives engineering teams tighter control over their CI/CD pipelines.
A minimal script and a few lines in vercel.json are enough to prevent redundant deployments, improve efficiency, and keep the release process aligned with branch strategy.