Deploying with Vercel CLI

Install Vercel CLI and deploy a local project with a single terminal command.

🎯 Introduction

In the previous article, we deployed through the web dashboard. Here, you will learn to use Vercel CLI to deploy a local project directly from your terminal.


🧱 Why Use the CLI?

Deploying through the dashboard requires pushing your code to GitHub first. Sometimes you want to test something quickly, or your code is not ready to commit. That is where the CLI helps.

Vercel CLI is Vercel's official command-line tool. It uploads a local directory directly to Vercel for deployment, without requiring a Git repository.

ComparisonWeb dashboardVercel CLI
Code sourceA Git repository such as GitHubDirect upload from a local directory
AutomationAutomatic deployment on pushRun commands manually
Best suited forProduction projects and team collaborationQuick tests and temporary demos

You can use both methods with the same project.


🚀 Install and Sign In

This course uses Node.js v22.0.0 and Vercel CLI 56.3.1.

Install it globally with npm:

npm install -g vercel@56.3.1

Verify the installation:

vercel --version

If the command prints a version number, you are ready to sign in:

vercel login

Follow the prompts and select Continue with GitHub. Your browser opens an authorization page. Once authorized, the terminal confirms that you are signed in.


📦 Your First CLI Deployment

Open the vercel-demo directory from the previous article (or any project directory) and run:

vercel

The first run asks several interactive questions. You can generally accept the defaults:

? Set up and deploy "~/vercel-demo"? [Y/n] y
? Which scope should contain your project? your-username
? Link to existing project? [y/N] n
? What's your project's name? vercel-demo
? In which directory is your code located? ./
The number, order, and wording of CLI prompts can change between versions. Answer the prompts you see; the key details are the project name and code directory.

After deployment, the terminal prints a preview URL:

✅ Preview: https://vercel-demo-xxxx.vercel.app

Open it to see your latest page.

Running vercel creates a .vercel folder in the project root containing project and account linking information. Add it to .gitignore to keep it out of your repository.

🏭 Preview vs. Production Deployments

Notice the Preview label before the URL. By default, the CLI creates a preview deployment with a temporary URL, leaving your live production version unchanged.

Once you have checked it, use --prod to deploy to production:

vercel --prod

This time, the URL is your production domain:

✅ Production: https://vercel-demo-xxxx.vercel.app

Think of these commands as a rehearsal and a live performance: test first, then release when you are satisfied. A later article compares these deployment types in more detail.


❓ Knowledge Check

Q1: Will a later git push conflict with a CLI deployment?

No. Each method creates a separate deployment record; the latest production deployment determines what is live. Choose one primary deployment method for a project to avoid confusion.

Q2: Do I need to sign in again on another computer?

Yes. Credentials are stored in your local user directory. Run vercel login on the other computer.

Q3: Does a CLI deployment automatically run npm run build?

Yes. The cloud build process is the same as with the dashboard. The CLI changes how the code reaches Vercel, from fetching Git code to uploading local files.

Q4: How do I sign out?

Run vercel logout to clear your local credentials.


🧪 Practice

  1. Install vercel@56.3.1 globally and complete vercel login.
  2. Change the homepage text locally and run vercel. Check the preview URL, then run vercel --prod to release it to production.
# Write your commands here

🎉 You now know how to use Vercel CLI! Next, we will explore project settings and environment variables for more flexible build configuration.