---
url: https://kit.kambium.net/docs/cloud-supabase.md
---
# Supabase

Connect the hosted Supabase project your deployed app will use for data and
sign-in. Desktop prepares the local database when you start **Local Server**.

In **Cloud → Supabase**, choose **Connect Supabase** and select your project.
Desktop saves the project URL and publishable key to the selected Fly TOML
file and stages the backend key as a Fly secret.

![Desktop showing Supabase connection checks and schema preparation in an example environment](https://kit.kambium.net/docs/assets/desktop-supabase-example-2026-11-24.CnQOa9SR.png)

<span id="check-api-access"></span>
<span id="prepare-schema-files-in-desktop"></span>

## Apply the hosted schema

Desktop checks the migration history after connecting. For a verified empty
dev database with only the Kit's initial schema pending, **Set up database**
gets the migration files and applies them to the named Supabase project.
Commit any new SQL with `supabase/kambium-schema.json`.

For production, upgrades, or app-specific SQL, review the target and pending
files before choosing **Apply migrations**. If Desktop prompts for Supabase CLI
or more project access, follow the prompt. **Migrations up to date** means the
hosted project has recorded the local migration files. If the project has
existing application data without matching history, see
[existing database adoption](#existing-databases-and-custom-urls).

<span id="configure-auth"></span>

Set up [sign-in](https://kit.kambium.net/docs/verify-deployment.md#configure-supabase-auth) once the dashboard
and backend have public URLs.

::: details Supabase access and CLI requirements

Desktop uses a scoped [Supabase personal access token](https://supabase.com/docs/guides/platform/personal-access-tokens)
for the current session. It passes the token to Supabase CLI v3.2 or newer
within v3 when applying migrations.

* To import the project keys, allow Projects (account-wide) Read, API Keys Read
  and API Key Secrets Read.
* To apply migrations, allow Database Read and Write, Database Pooling
  Configuration Read and Production Branches Read for the project.
* To apply sign-in URLs, allow Auth Configuration Read and Write and Project
  Admin Write for the project.

You can also enter [Supabase keys](https://kit.kambium.net/docs/environment-variables.md#supabase) directly
in Cloud → Configuration.

:::

::: details Set up without Desktop

Run from the app directory with Supabase CLI 3.2 or newer within v3. The Kit's
database commands expect `supabase/config.toml`. Initialize the project if it
has no Supabase configuration, then authenticate:

```sh
supabase init
supabase login
```

If `supabase init` created `supabase/config.jsonc`, run
`supabase config convert --to toml` before applying migrations.
[Supabase CLI config change](https://supabase.com/changelog/supabase-cli-config-jsonc-default)

For a new, empty hosted database:

```sh
npm run db:init -- --remote=your-project-ref
```

Replace `your-project-ref` with the ID in `https://<project-ref>.supabase.co`.
This imports the required SQL and applies all pending project migrations,
including application SQL. Check the displayed target and SQL before confirming.

For file preparation without application, use `kambium db export init`, then
review and commit SQL plus `supabase/kambium-schema.json`. Apply prepared files
with `kambium db upgrade --remote=your-project-ref`. Local development may already
have prepared them. Desktop displays that command with the target filled in.

An authenticated Supabase operator session is needed to apply hosted migrations,
including a command copied from Desktop. See the
[Supabase CLI setup](https://supabase.com/docs/guides/local-development/cli/getting-started)
and [CLI database contract](https://github.com/MartinMalinda/kambium/blob/main/packages/cli/README.md#database-setup-and-upgrades).
Deployment and hosted app startup do not apply migrations.

:::

::: details Interpreting checks or retrying a migration

API checks cover connectivity and access to core tables. The migration review
compares recorded timestamps with local files, and does not inspect the full
hosted schema. Recheck migration history after a failure or cancellation before
trying again. Resolve missing or out-of-order history before applying changes.

:::

<span id="existing-databases-and-custom-urls"></span>

::: details Existing databases and custom URLs

Existing databases need a reviewed adoption baseline before importing upgrades;
do not apply a fresh snapshot over them. Modified SQL, invalid import metadata
and unsupported upgrade paths stop preparation. See the
[schema delivery contract](https://github.com/MartinMalinda/kambium/blob/main/packages/core/database/delivery.md).

For custom project URLs, select the migration target explicitly in the terminal.
Desktop application supports standard hosted project URLs only.

For package and schema upgrades, follow [Update your application](https://kit.kambium.net/docs/updating.md).

:::
