Vercel Logo

Install and Authenticate the Vercel CLI

A global CLI installed during an old workshop has a remarkable ability to reappear at the worst time. Before we open either app, we'll install a current Vercel CLI and connect it to the account we intend to use.

Outcome

Install the Vercel CLI and verify that it can access your Vercel account.

Hands-on exercise 1.1

Install

The CLI ships as an npm package. Install it globally so you can run it from anywhere:

npm install -g vercel

The CLI requires Node.js. If node --version fails, install the LTS release from nodejs.org before continuing.

Authenticate

Once installed, log into your Vercel account:

vercel login

The CLI starts an OAuth device flow and prints a verification URL. Open the URL on any browser-capable device, check that the location and request time match, then approve the login. The terminal confirms when authentication finishes:

> Success! Authentication complete.

Verify

Confirm the CLI is installed and authenticated:

vercel --version
vercel whoami

The first command prints the CLI version. The second confirms which account is active.

Token-based auth

In CI, authenticate with a Vercel access token instead of an interactive login. Pass the token to CLI commands with the --token option.

Try It

Run both commands and check the output:

vercel --version
Vercel CLI 59.1.4

FastAPI projects require Vercel CLI 48.1.8 or newer. If your version is older, upgrade with npm install -g vercel@latest before moving on.

vercel whoami
your-vercel-username

If vercel whoami returns your username, authentication worked. If the command reports that you're logged out, run vercel login again.

Multiple accounts

The CLI stores one active session at a time. If you have a personal and a work Vercel account, vercel login will switch you to whichever you authenticate as. Run vercel whoami any time you're unsure which account is active.

Commit

We haven't changed any project files, so there is nothing to commit yet.

Troubleshooting

vercel login waits for approval: Open the verification URL printed in the terminal and enter the device code if prompted. The browser can be on another device.

vercel: command not found after install: The global npm bin directory may be missing from your PATH. Run npm config get prefix to locate it, then add its bin directory to your PATH. You can also run the CLI through npx vercel.

Done-When

  • vercel --version prints a version number
  • vercel whoami returns your Vercel username

Solution

npm install -g vercel
vercel login
vercel --version  # prints Vercel CLI 48.1.8 or newer
vercel whoami     # prints your Vercel username

Was this helpful?

supported.