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
npx @supatype/cli loginThis 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.
Step 2: Link your project
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:
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
npx supatype deployThis command:
- Sends your schema to the linked project, which diffs it against the Cloud database
- Applies the changes without asking
- Builds and uploads your static site, when
supatype.config.tshas abuildsection
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
npx supatype deploy --env stagingnpx supatype deploy --env productionThe 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
npx supatype deploy --schema-only # push the schema, skip the appnpx supatype deploy --app-only # deploy the static site, skip the schemaCI/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 Cloudon: 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 --yesPreview 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 --yesRollback
If a deployment causes issues, roll the static site back to the previous deployment:
npx supatype deploy rollbackOr roll back to a specific deployment:
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
npx supatype deploy statusnpx 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:
npx supatype functions env set MY_API_KEY=sk-123456List environment variables (the values are masked):
npx supatype functions env listTo set a value for one function only, add --function <name>. A function’s own value overrides a shared one with the same name:
npx supatype functions env set MY_API_KEY=sk-123456 --function send-email