Deploying with Vercel CLI
🎯 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.
| Comparison | Web dashboard | Vercel CLI |
|---|---|---|
| Code source | A Git repository such as GitHub | Direct upload from a local directory |
| Automation | Automatic deployment on push | Run commands manually |
| Best suited for | Production projects and team collaboration | Quick 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? ./
After deployment, the terminal prints a preview URL:
✅ Preview: https://vercel-demo-xxxx.vercel.app
Open it to see your latest page.
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
- Install
vercel@56.3.1globally and completevercel login. - Change the homepage text locally and run
vercel. Check the preview URL, then runvercel --prodto 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.
