# Render (/docs/cli/deploy/render)

In a project with `deploy render` (CLI 0.29.0 or newer), `pnpm clubedge deploy` uses [Render's API](https://api-docs.render.com) with an API key:

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

## Before you start [#before-you-start]

- **Push the project.** Render builds the `Dockerfile` from your Git repository, not from your machine. The `origin` remote must be on GitHub, GitLab, or Bitbucket, and the current branch pushed; `deploy` stops when it isn't, and warns about commits that aren't pushed yet.
- **Give Render access to the repository**, in the dashboard under your account's Git settings. Render can't build a repository it can't read.
- **Put `DATABASE_URL` in [`.env.production`](./index.mdx#provider-keys)**: Render Postgres, Neon, or Supabase. `deploy` creates no database on Render.

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

1. **Signs in with an API key.** With `RENDER_API_KEY` set, it uses that. Otherwise it opens the dashboard's API keys page and asks you to paste a key; it doesn't store it, so set `RENDER_API_KEY` to skip the question next time. With several workspaces, it asks which one.
2. **Creates or reuses the web service**, named after the package, as [`render.yaml`](../../starter/deploy/render.mdx) describes it: the Docker runtime on a starter instance, `node /app/migrate.mjs` as the pre-deploy command, the `/api/health` check, and a new deploy on each push to the branch.
3. **Sets the production variables:** the [env file's](./index.mdx#provider-keys) values, the service's `*.onrender.com` URL as `APP_URL` and `NEXT_PUBLIC_APP_URL`, `CLIENT_IP_HEADER=cf-connecting-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. On an existing service, it changes only the values that differ.
4. **Deploys and waits** until Render reports the release live: Render builds the image, runs the migrations before the release, and checks `/api/health`. The first build takes several minutes.
5. **Fixes the public URL.** When Render gives the service another subdomain (the name was taken), `deploy` sets that URL, cancels the deploy that creating the service started, and deploys again, since Next.js compiles the URL into the build.

## Costs [#costs]

<Callout type="warn">
  `deploy` creates the service on Render's starter instance type, which Render bills monthly: pre-deploy commands, which run the migrations before each release, need a paid type. For the free type, create the service yourself from the [Blueprint](../../starter/deploy/render.mdx) without `preDeployCommand`, and run the migrations yourself.
</Callout>

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

`deploy` prints the status the deploy ended with (`build_failed`, `pre_deploy_failed`, `update_failed`) and the service's dashboard link, where the build and deploy logs say why. A `pre_deploy_failed` is a failed migration: check `DATABASE_URL`. Fix the cause and run `deploy` again, which reuses the service.

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