# Vercel (/docs/cli/deploy/vercel)

In a project with `deploy vercel` (CLI 0.28.0 or newer), `pnpm clubedge deploy` uses [Vercel's CLI](https://vercel.com/docs/cli) and your Vercel login:

```sh
pnpm clubedge add deploy vercel   # if the project deploys elsewhere today
pnpm clubedge deploy
```

Vercel only runs the app, so the database, Redis, storage, and email come from your providers. Put their production values in [`.env.production`](./index.mdx#provider-keys) first: `deploy` stops without `DATABASE_URL`. Use your provider's pooled URL (Neon's pooled endpoint, Supabase's transaction pooler), since each serverless function opens its own connection.

## What it does [#what-it-does]

1. **Signs in** with `vercel login` when `vercel whoami` finds no login, which opens the browser. Once you are signed in, later runs skip this.
2. **Creates or reuses the project**, named after the package, with `apps/web` as its Root Directory: Vercel uploads the whole workspace and builds the app. On a project you created earlier, it sets the Root Directory when it differs, then links the folder (`.vercel/project.json`).
3. **Writes `.vercelignore`** when the project has none, from what Git ignores, so `.env` files and build output never leave your machine. Commit it.
4. **Sets the production variables** in one request: the [env file's](./index.mdx#provider-keys) values, the public URL as `APP_URL` and `NEXT_PUBLIC_APP_URL`, `CLIENT_IP_HEADER=x-real-ip`, where the [client's address](./index.mdx#client-addresses) is (CLI 0.42.0 or newer), and with Better Auth a generated `BETTER_AUTH_SECRET` that later runs keep. Secrets are stored encrypted; `STORAGE_DIRECTORY` is left out, since Vercel keeps no disk.
5. **Runs `vercel deploy --prod`** and streams the build log. The build runs `check:env`, then the migrations against `DATABASE_URL`, then the app's build.
6. **Fixes the public URL.** When Vercel names the app something other than `https://<project>.vercel.app` (the name was taken), `deploy` sets that URL and deploys again, since Next.js compiles it into the build.

## Vercel's CLI [#vercels-cli]

`deploy` needs Vercel CLI 50.5.1 or newer, for `vercel api`. It uses an installed `vercel` when it is new enough, else the latest through npx. Installing it once makes `deploy` faster:

```sh
npm install -g vercel
```

## Costs [#costs]

Vercel bills usage on your plan. Your database and other services bill on their own plans.

## When a deploy fails [#when-a-deploy-fails]

The build log above the error says why. Most often `check:env` names a missing variable: add it to `.env.production` and run `deploy` again, which reuses the project. `vercel inspect --logs <url>` shows a deployment's log again, and `vercel logs <url>` the running app's.

To set up Vercel without this command, see [Vercel](../../starter/deploy/vercel.mdx) in the deploy guide.
