Skip to content

How can I use the Vercel CLI for custom workflows?

You can use the Vercel CLI with any CI/CD provider such as Azure DevOps to generate Preview Deployments for every git push and deploy to Production when code is merged into the main branch.

This approach is useful for developers who want full control over their CI/CD pipeline as well as those who can’t leverage Vercel’s built-in git integration. Another use for this setup would be a trunk-based development workflow.

Building Your Application

You can build your application locally (or in a pipeline) without giving Vercel access to the source code through vercel build. Vercel automatically detects your frontend framework and generates a .vercel/output folder conforming to the Build Output API specification.

vercel build allows you to build your project within your own CI setup and upload only those build artifacts (and not the source code) to Vercel to create a deployment.

Creating a Custom Workflow

  1. Retrieve your Vercel Access Token
  2. Install the Vercel CLI and run vercel login
  3. Inside your folder, run vercel link to create a new Vercel project
  4. Inside the generated .vercel folder, save the projectId and orgId from the project.json
  5. Add VERCEL_TOKEN, VERCEL_ORG_ID, and VERCEL_PROJECT_ID as environment variables in your CI/CD provider
$ npm install --global vercel vercel pull --yes --environment=preview --token=YOUR_VERCEL_TOKEN vercel build --token=YOUR_VERCEL_TOKEN vercel deploy --prebuilt --token=YOUR_VERCEL_TOKEN

These Vercel CLI commands enable any custom workflow

Examples of Custom Workflows

The following examples show how to use the Vercel CLI as shown above:

Couldn't find the guide you need?