Skip to content
Tutorials Center
My learning

Topics

Lesson 5 of 37 ยท Getting Started

Vercel and Netlify CLI Basics

Learn the commands you use daily in the Vercel CLI and Netlify CLI: login, link, dev, deploy, env, logs and rollback, with a side-by-side cheat sheet and a command parser.

The dashboard is fine for setup, but the command line is where you will spend most of your time: running the site locally with the same behavior as production, pulling environment variables, deploying from scripts and reading logs. Both platforms ship an official CLI that follows the same pattern.

This lesson covers installation, authentication, linking a folder to a project and the commands you will reach for daily. It does not show command output, because we only describe what we can state with certainty.

Install and log in

Install globally with npm, or run without installing using npx.

Terminal
npm install --global vercel
npm install --global netlify-cli

vercel login
netlify login

Both open a browser window to authorize the CLI. For CI servers, where nobody can click a browser, you use a token instead: Vercel accepts --token or the VERCEL_TOKEN environment variable, and Netlify uses NETLIFY_AUTH_TOKEN (plus NETLIFY_SITE_ID to name the target site). Create these tokens in your account settings and store them as CI secrets, never in the repository.

Linking a folder to a project

The CLI needs to know which remote project a local folder belongs to.

Task Vercel Netlify
Link to an existing project vercel link netlify link
Create and link a new one vercel (first run) netlify init or netlify sites:create
See who you are vercel whoami netlify status

Vercel writes the link into a .vercel folder (with a project.json holding IDs), and Netlify stores it in .netlify/state.json. Add both folders to .gitignore. They are local pointers, not source code.

Local development with platform behavior

A plain framework dev server does not know about your functions, redirects or environment variables. The platform dev servers do:

Terminal
vercel dev      # runs your framework plus Vercel Functions locally
netlify dev     # runs your framework plus Netlify Functions, redirects, edge functions

netlify dev reads netlify.toml, proxies your framework's dev server and serves functions at /.netlify/functions/NAME. Many modern frameworks run happily with just their own dev command, so use the platform dev server when you need functions or platform-specific rewrites to work exactly as in production.

Deploying

Terminal
vercel                  # preview deployment
vercel --prod           # production deployment
netlify deploy          # draft deploy (asks for the publish folder the first time)
netlify deploy --prod   # production deploy
netlify deploy --build  # run the build locally first, then deploy it

Important detail: netlify deploy uploads a folder you already built, while a Git push makes the platform build for you. The Vercel CLI uploads your source and builds remotely by default. You can also build locally and upload the result, using vercel build followed by vercel deploy --prebuilt, which is useful in CI systems that want full control over the build.

Environment variables from the terminal

Terminal
vercel env add API_KEY production    # prompts for the value
vercel env ls
vercel env pull .env.local           # download development values to a file

netlify env:set API_KEY "secret"     # sets for the linked site
netlify env:list
netlify env:import .env              # bulk import

vercel env pull and netlify dev (which injects site variables) let your local run match the cloud. The environment variables lesson explains scopes in detail.

Logs and rollback

Terminal
vercel logs <deployment-url>     # runtime logs for a deployment
vercel rollback                  # roll production back to the previous deployment
vercel promote <deployment-url>  # make a chosen deployment the production one

netlify logs:function <name>     # stream a function's logs
netlify deploy --prod --dir=dist # re-publish a known good build folder

On Netlify the usual rollback is in the dashboard: open Deploys, select an older deploy and choose Publish deploy. Rollbacks cover this in depth.

Cheat sheet

Goal Vercel Netlify
Log in vercel login netlify login
Run locally vercel dev netlify dev
Preview deploy vercel netlify deploy
Production deploy vercel --prod netlify deploy --prod
Pull env values vercel env pull netlify env:list / netlify dev
Open dashboard vercel project inspect netlify open
Help vercel help netlify help

Run <cli> help or <cli> <command> --help to see exactly what your installed version supports. CLIs add commands over time.

A tiny command parser

CLIs are mostly "a command, some arguments and flags". This stand-in parses command lines the same way and tells you which environment each one would affect. It does not call any real service.

Node.js CLI command explainer (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Node.js Safety check before you deploy (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which command runs your site locally together with Netlify Functions and redirects?

    netlify dev proxies your framework and emulates functions, redirects and edge functions.
  2. 2. How should a CI server authenticate with the CLI?

    Tokens such as VERCEL_TOKEN or NETLIFY_AUTH_TOKEN are made for non-interactive use.
  3. 3. What should you do with the .vercel and .netlify folders?

    They hold local pointers to the linked project and are not source code.
  4. 4. What does vercel --prod do that plain vercel does not?

    Without the flag, Vercel creates a preview deployment.

Summary

  • Install with npm, authenticate with login (or tokens in CI), and link a folder to a project.
  • vercel dev and netlify dev mimic the platform locally, including functions.
  • CLIs deploy previews by default; --prod targets production.
  • Both can manage environment variables, show logs and help with rollback.
  • Keep .vercel and .netlify out of Git, and guard production deploys in scripts.

Next: Git Integration and Automatic Deploys