# Deploy with one command (/docs/cli/deploy)

`pnpm clubedge deploy` deploys a project to the platform it was created for, with the platform's own CLI or API and your login. Sign in when it asks, and it does the rest: the project or service, the databases where the platform hosts them, the production variables, the public URL, and the release. With `docker`, it prepares [Docker Compose](./docker.mdx) for a server of your own instead.

```sh
pnpm clubedge deploy             # asks before creating anything; reads .env.production
pnpm clubedge deploy --dry-run   # the plan, nothing created
```

<Callout type="warn">
  It creates resources in your account on the platform, which bills their usage on your plan. It asks first; `--yes` agrees.
</Callout>

## Platforms [#platforms]

Each platform has its own page: what `deploy` creates there, how it signs in, and what to do when a deploy fails.

| Platform | Deploy option | Since | What runs where |
| --- | --- | --- | --- |
| [Railway](./railway.mdx) | `railway` | CLI 0.22.0 | The app, Postgres, and Redis on Railway, or your own databases |
| [Fly.io](./fly.mdx) (experimental) | `fly` | CLI 0.25.0 | The app, Postgres, and Upstash Redis on Fly.io, or your own databases |
| [Vercel](./vercel.mdx) (experimental) | `vercel` | CLI 0.28.0 | The app on Vercel; the databases and services from your providers |
| [Netlify](./netlify.mdx) (experimental) | `netlify` | CLI 0.29.0 | The app on Netlify; the databases and services from your providers |
| [Render](./render.mdx) (experimental) | `render` | CLI 0.29.0 | The app on Render, built from your Git repository; the database from your provider |
| [Docker Compose](./docker.mdx) | `docker` | CLI 0.42.0 | The app behind Caddy on a server of your own, its images on GitHub's container registry |

The platform comes from the project's `deploy` module. Switch it with `pnpm clubedge add deploy <option>`. With `docker`, `deploy` writes the Compose files for a server of your own; for another container host, follow the [deploy guide](../../starter/deploy/container-host.mdx).

A [frontend and its API](../frontend-and-api.mdx) deploy with `docker` or `railway` (CLI 0.35.0 or newer): `deploy` sets up both services, with the frontend public and the API private. With `docker`, it writes a `compose.yaml` that runs both behind Caddy, the API on the Compose network ([Docker Compose](./docker.mdx)); on Railway, see [A frontend and its API](./railway.mdx#a-frontend-and-its-api).

A project [without a website](../without-a-website.mdx) deploys its API alone, as the one public service, with `docker` or `railway` (CLI 0.44.0 or newer): behind Caddy with [Docker Compose](./docker.mdx), or on [Railway](./railway.mdx#without-a-website) with its own `*.up.railway.app` domain. Fly.io, Vercel, Netlify, and Render deploy a web app, so `deploy` refuses them there.

A [mobile app](../../starter/mobile-app.mdx) or a [native app](../../starter/native-app.mdx) runs no server, so `deploy` leaves it out. The steps below describe one app on a hosted platform.

<Callout>
  Experimental platforms work end to end but are newer: their steps or messages may still change between releases. Run `--dry-run` first, and report anything that goes wrong.
</Callout>

## What every platform does [#what-every-platform-does]

1. **Signs in.** The platform's login opens in the browser when you are signed out (Render asks for an API key instead). With a token in the environment, nothing opens.
2. **Creates or reuses** what the app runs on, named after the package: a Railway service, a Fly app, a Vercel project, a Netlify site, or a Render web service. A second run finds it again.
3. **Sets the production variables:** your [provider keys](#provider-keys), the public URL as `APP_URL` and `NEXT_PUBLIC_APP_URL`, with Better Auth a generated `BETTER_AUTH_SECRET` that later runs keep, and where the app finds a [client's address](#client-addresses).
4. **Deploys and waits.** The migrations run before the release, and `deploy` prints the URL once the platform reports the release live.

Running it again reuses everything, so it also ships a new release and adds variables.

## Provider keys [#provider-keys]

The platform can't guess your storage, email, or payment keys. Put the production values in `.env.production` at the project's root (Git ignores it), and `deploy` reads it (CLI 0.26.0 or newer; older releases need `--env-file`). For another file, pass it:

```sh
pnpm clubedge deploy                              # reads .env.production when there is one
pnpm clubedge deploy --env-file .env.staging      # or another file
```

Variables that `.env.example` lists and nothing sets are reported as **Not set**, for the modules that need them, before the build starts.

## Your own databases [#your-own-databases]

CLI 0.26.0 or newer. On Railway and Fly.io, without `DATABASE_URL` and `REDIS_URL` in the env file, the platform hosts everything. With them, `deploy` creates neither and the platform only runs the app: for example Postgres on Supabase or Neon, Redis on Upstash, and files on Cloudflare R2.

On Vercel, Netlify, and Render, `DATABASE_URL` always comes from the env file: those platforms only run the app. Use your provider's pooled connection URL on Vercel and Netlify, where each serverless function opens its own connection (Supabase's transaction pooler or Neon's pooled endpoint).

```sh title=".env.production"
DATABASE_URL=postgresql://postgres.abc:password@aws-0-eu-west-1.pooler.supabase.com:6543/postgres
REDIS_URL=rediss://default:password@eu1-example.upstash.io:6379
STORAGE_ENDPOINT=https://<account-id>.r2.cloudflarestorage.com
# ...the other keys your modules use
```

With a `DATABASE_URL` in the env file, `deploy` also sends `DATABASE_URL_DIRECT` (CLI 0.30.0 or newer), the direct connection that migrations and the jobs worker use: the file's value, or for a pooled Neon URL the same URL without `-pooler`. It never sends one next to the platform's own database. Before deploying the free Neon database the CLI created, it warns that Neon deletes it unless you [claim it](../neon.mdx).

Each one decides for itself: only `DATABASE_URL` keeps Redis on the platform. URLs to `localhost` (from a development env file) are ignored with a warning. A later `deploy` without the env file keeps the URL the service already has. When you move from the platform's database to your own, the old one stays in the project, unused: delete it in the dashboard once you no longer need its data.

## Client addresses [#client-addresses]

Rate limits and logs count each visitor by address, which the platform's proxies hide. From CLI 0.42.0, `deploy` tells the public service where to find it, for projects from Starter v0.27.0 on:

| Platform | Setting |
| --- | --- |
| Railway, Vercel | `CLIENT_IP_HEADER=x-real-ip` |
| Render | `CLIENT_IP_HEADER=cf-connecting-ip` |
| Fly.io | `CLIENT_IP_HEADER=fly-client-ip` |
| Netlify | `CLIENT_IP_HEADER=x-nf-client-connection-ip` |
| Docker Compose | `TRUSTED_PROXY_HOPS=1`: Caddy is the one proxy of your own that sets `X-Forwarded-For` |

`CLIENT_IP_HEADER` names the header the platform's edge sets to the client's address, replacing any copy the client sent. A frontend's API, reached only through the frontend's server, which sends on the one address it found, gets `TRUSTED_PROXY_HOPS=1` and never `CLIENT_IP_HEADER`. An API without a website is the public service itself, so it gets its platform's setting. Previews get the same as production, and [`try`](../try-on-railway.mdx) sets `x-real-ip` on its Railway VM.

Either setting in the env file replaces both defaults, for another proxy in front. Neither is ever reported as unset, and projects from Starters before v0.27.0 ignore them. See [Client addresses](../../starter/before-deploying.mdx#client-addresses) for how the app reads them.

## Previews [#previews]

On Vercel and Railway, `pnpm clubedge deploy --preview` deploys the current Git branch next to production, with its own branch of the Neon database. It deploys a web app only, not a frontend and its API, nor a project without a website. See [Preview deployments](./preview.mdx).

## Deploying by hand [#deploying-by-hand]

`deploy` is a shortcut, not a requirement. Each platform's page in the [deploy guide](../../starter/deploy/index.mdx) covers the same setup by hand, the files the project ships for it, and the deploy workflow for GitHub Actions.
