Skip to content

Deploying to Cloud

Prerequisites

  • A Supatype Cloud account. Cloud is in a closed beta: a new account cannot create a project until it is approved, and the dashboard says “You can create a project as soon as your account is approved” until then.
  • The Supatype CLI installed
  • A local Supatype project

Step 1: Log in

Terminal window
npx @supatype/cli login

This opens your browser. Approve the sign-in there, then type the code the page shows into the terminal. The CLI stores a personal access token locally, and never asks for your password. If the browser does not open, the URL to visit is printed (--no-browser prints it without trying).

To use a Cloud other than supatype.com, pass --api-url <url> or set SUPATYPE_API_URL.

On a machine with no terminal, such as CI, create a personal access token in your account and use it instead: supatype login --token <spt_...>, or set SUPATYPE_ACCESS_TOKEN.

Create the project in the Cloud dashboard if it does not exist yet, then link your local project to it by its slug or its ref:

Terminal window
npx @supatype/cli link --project <project-slug>

Once linked, supatype projects list shows the slugs of the other projects in the same organisation.

Step 3: Deploy

Terminal window
npx supatype deploy

This command:

  1. Sends your schema to the linked project, which diffs it against the Cloud database
  2. Applies the changes without asking
  3. Builds and uploads your static site, when supatype.config.ts has a build section

If policies, grants, labels or row level security were changed outside Supatype, the deploy refuses. Review the changes with supatype push, or pass --overwrite-drift to put Supatype’s definitions back.

Edge functions are not part of deploy; ship them with supatype functions deploy.

Who can deploy

Your role in the project’s organisation decides. Owners, admins and developers can push the schema, deploy, roll back and delete static site deployments, deploy and delete functions and hooks, and set function secrets. Viewers can read function and deployment logs. Editor and billing members can do none of these, and a refused request answers “Only the organisation’s owners, admins and developers can deploy code or set its secrets”. API keys and custom domains stay with owners and admins. See Studio Roles.

Deploy to a specific environment

Terminal window
npx supatype deploy --env staging
npx supatype deploy --env production

The environment must exist first (see Environments), and the link must know it: supatype envs create records the environment it creates, and running supatype link again picks up one created in the dashboard. supatype envs list shows the environments the link knows.

--env chooses where the schema goes. The static site is not split by environment: a project has one live site, and deploying an app with --env staging replaces it. Use --schema-only for anything that is not production.

Deploy only part of the project

Terminal window
npx supatype deploy --schema-only # push the schema, skip the app
npx supatype deploy --app-only # deploy the static site, skip the schema

CI/CD deployment

GitHub Actions

In CI there is no browser, so use a personal access token. Create one in your account, store it as a secret, and set it as SUPATYPE_ACCESS_TOKEN; the CLI reads it directly, with no login step:

name: Deploy to Supatype Cloud
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
env:
SUPATYPE_ACCESS_TOKEN: ${{ secrets.SUPATYPE_ACCESS_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install
- run: npx supatype link --project ${{ vars.SUPATYPE_PROJECT }}
- run: npx supatype deploy --yes

Preview deployments

For pull requests, push the schema to the project’s preview environment. The preview environment must exist, and it expires 7 days after it is created, so create it again with supatype envs create preview once it has gone. --schema-only keeps the pull request’s app away from the live site:

on:
pull_request:
jobs:
preview:
runs-on: ubuntu-latest
env:
SUPATYPE_ACCESS_TOKEN: ${{ secrets.SUPATYPE_ACCESS_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install
- run: npx supatype link --project ${{ vars.SUPATYPE_PROJECT }}
- run: npx supatype deploy --env preview --schema-only --yes

Rollback

If a deployment causes issues, roll the static site back to the previous deployment:

Terminal window
npx supatype deploy rollback

Or roll back to a specific deployment:

Terminal window
npx supatype deploy rollback --to <version>

--to takes a deployment’s version, which supatype deploy status shows for the live one, or its id. Omit --to to roll back to the immediately previous version. Rollback restores the site, not the database schema.

Deployment status and logs

Terminal window
npx supatype deploy status
npx supatype deploy logs <version>

deploy status shows the live deployment’s version, size and deploy time. deploy logs prints the build logs of the deployment with that version or id.

Environment variables

Set environment variables for your project’s edge functions:

Terminal window
npx supatype functions env set MY_API_KEY=sk-123456

List environment variables (the values are masked):

Terminal window
npx supatype functions env list

To set a value for one function only, add --function <name>. A function’s own value overrides a shared one with the same name:

Terminal window
npx supatype functions env set MY_API_KEY=sk-123456 --function send-email