# Netlify (/docs/cli/deploy/netlify)

In a project with `deploy netlify` (CLI 0.29.0 or newer), `pnpm clubedge deploy` uses [Netlify's CLI](https://docs.netlify.com/cli/get-started/) and your Netlify login:

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

Netlify 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 `netlify login`, which opens the browser when you are signed out and returns at once when you are signed in. With `NETLIFY_AUTH_TOKEN` set, it skips this.
2. **Creates or reuses the site.** It reuses the site the project is linked to (`.netlify/state.json`), or `<name>.netlify.app` when it is yours. Otherwise it creates the site in your team, named after the package, with a short suffix when the name is taken, since Netlify's names are global. The base directory is `apps/web`, where `netlify.toml` is; on an existing site, `deploy` sets it when it differs.
3. **Sets the production variables** with `netlify env:import`, from a private temporary file it deletes afterwards, so no value appears on a command line: the [env file's](./index.mdx#provider-keys) values, the site URL as `APP_URL` and `NEXT_PUBLIC_APP_URL`, `CLIENT_IP_HEADER=x-nf-client-connection-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. `STORAGE_DIRECTORY` is left out, since Netlify keeps no disk.
4. **Runs `netlify deploy --build --prod`.** The build runs on your machine with the site's variables: `check:env`, the migrations against `DATABASE_URL`, then the app's build with Netlify's runtime. The result is uploaded and published.

The site's URL is known before the build, so one deploy is enough.

## Netlify's CLI [#netlifys-cli]

`deploy` uses an installed `netlify`, else the latest `netlify-cli` through npx. It is a large package, so installing it once makes `deploy` much faster:

```sh
npm install -g netlify-cli
```

## Costs [#costs]

Netlify 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 site. Since the build runs on your machine, `pnpm install` must have run and the build must pass locally. `netlify open` opens the site's dashboard, with its deploys and function logs.

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