Skip to content

Get started

Run the stack on your machine, self-host it with Docker Compose, ship changes and upgrade Supatype components.

Pre-1.0: APIs and config may change between releases.

Local development

Install the CLI, scaffold a project, and run the full stack on your machine. Supatype runs it in Docker by default. Choose Native during supatype init if you would rather use host binaries and no Docker.

1. Install the CLI

Terminal window
$ npm install -g @supatype/cli

The CLI needs Node.js 18 or later. Vite 8, which supatype init sets up for a Vite app, needs Node.js 20.19 or later, or 22.12 or later on Node 22. For a machine without Node, the CLI page has a standalone binary. The first run downloads the binaries it needs into ~/.supatype/cache/.

On Linux and macOS you can also use the install script or Homebrew. On Windows, use npm.

Terminal window
$ curl -fsSL https://supatype.com/install.sh | bash
$ brew install supatype/tap/supatype

2. Create a project

Terminal window
$ mkdir my-app && cd my-app
$ supatype init

supatype init writes package.json, supatype.config.ts, a starter schema and public/, installs dependencies with your package manager and writes the API keys to .env. Run npm install or supatype keys --write yourself only if you passed --no-install or --no-keys. Pass -y to take every default without being asked.

It also writes seed.ts and an empty seeds/ for seeding. package.json lists @supatype/cli and @supatype/types as dev dependencies, because they run only at build time. The passwords and the JWT secret in .env are random for each project.

3. Start the stack

Terminal window
$ supatype dev

supatype dev applies your schema when it starts, then watches it: each save migrates the database and regenerates the typed client. It keeps running, so use a second terminal for other commands. supatype push applies the schema to another database, such as a server you deploy to.

It stops with its stack when the process that started it exits, as it does on Ctrl+C: a script that is killed, or a cancelled CI job, leaves nothing running. To leave a stack running with nothing attached, use supatype self-host compose up -d.

A script that starts dev in the background should exec it, so the process ID the script holds is dev itself and stopping it stops the stack cleanly:

Terminal window
(cd my-app && exec npx supatype dev) &
DEV_PID=$!
# ... run your tests ...
kill "$DEV_PID"; wait "$DEV_PID"

If dev itself is killed (its process ended, or its window closed before it finished stopping), the stack can be left running. The next supatype dev finds it and offers to stop it, and supatype self-host compose down stops it now.

The gateway serves REST at /rest/v1/, auth at /auth/v1/, storage and realtime. With Docker it listens on http://localhost:<gateway-port>: init picks a free port per project and writes the URL to .env as API_EXTERNAL_URL (the port alone is SUPATYPE_KONG_PORT). With Native it listens on http://localhost:18471, server.port in supatype.config.ts.

For direct SQL, Docker publishes Postgres on 127.0.0.1 at SUPATYPE_DEV_DB_PORT (54329 unless set), and dev points DATABASE_URL in .env at it. Native Postgres listens on port 5432 and checks passwords: connect as postgres with POSTGRES_PASSWORD from .env, or run supatype pg psql, which passes it for you.

4. Sign in to Studio

When the stack is up, supatype dev prints a Services running panel with each address. With Docker, Studio is at /studio/ on the gateway: http://localhost:<gateway-port>/studio/.

If you asked init for an admin, it wrote SUPATYPE_ADMIN_EMAIL and SUPATYPE_ADMIN_PASSWORD to .env. The first supatype dev or supatype push that finds no Studio admin creates one from them with the admin role, then removes the password from .env. Sign in with that email and password. To add one later, run supatype admin create-user --email you@example.com, which asks for the password.

5. Know what init scaffolded

schema/index.ts starts with two models:

  • Profile: one row per signed-in user, keyed by the auth user id. Any signed-in user can read profiles, and only the owner can create, update or delete theirs.
  • SiteSettings: a singleton with a site_name, readable by everyone and editable by admins in Studio under Settings.

6. Add a model

Add a Post to schema/index.ts and save. The running supatype dev migrates the database and regenerates the typed client. There is nothing to push locally.

schema/index.ts
import type { Model, UUID, SupatypeAuthUserId, Slug, Unique, Public, Owner } from "@supatype/types"
export type Post = Model<{
id: UUID
title: string
slug: Unique<Slug<"title">>
body: string
author_id: SupatypeAuthUserId
}, {
access: { read: Public; create: Owner<"author_id">; update: Owner<"author_id">; delete: Owner<"author_id"> }
}>

Merge the new names into the file’s existing import type line. The table is post. See Schema for field types, relations and access rules.

A change that would lose data, such as dropping a column, is never applied silently: dev asks first. To rename a column or table rather than drop it, see Renames.

7. Query it

Install the client first with npm install @supatype/client: the generated file builds on it. Then create the client once, from the generated file, with the URL and key init wrote to .env:

src/supatype.ts
import { createClient } from "../supatype/generated/client"
export const supatype = createClient({
url: import.meta.env.VITE_SUPATYPE_URL,
anonKey: import.meta.env.VITE_SUPATYPE_ANON_KEY,
})
src/posts.ts
import { supatype } from "./supatype"
const { data: posts, error } = await supatype.from("post").select("id, title, slug")
if (error) throw new Error(error.message)

The result is typed from your schema. The Client page covers filters, writes, auth, storage and realtime.

Serve your frontend dev server at /

Keep the committed supatype.config.ts pointing at your production build, and proxy to Vite or Next from a gitignored supatype.local.config.ts:

supatype.local.config.ts
// supatype.local.config.ts (your machine only)
export default {
app: { mode: "proxy", upstream: "http://localhost:5173" },
}

Restart supatype dev after changing config. The APIs stay on their own paths.

Self-hosting

Run the whole platform on a server you own with Docker Compose. The project layout is the same one you use locally, so the repository you develop in is the one you deploy.

1. Prepare the server

Ubuntu 22.04 or similar, Docker with Compose v2, Node.js (18 or later for the CLI, 20.19 or later, or 22.12 or later on Node 22, to build a Vite 8 app), and the CLI:

Terminal window
$ npm install -g @supatype/cli

2. Scaffold and set secrets

Terminal window
$ mkdir my-app && cd my-app
$ supatype init

init installs dependencies and writes generated secrets and API keys to .env. Set your public URLs there.

3. Start Compose

Terminal window
$ supatype self-host compose up -d
$ supatype push

compose up writes the compose file itself, so there is no separate render step. Once the stack answers, it creates the storage buckets the schema declares and the first admin user, as supatype dev does. The gateway listens on http://<your-host>:<gateway-port>, the port in SUPATYPE_KONG_PORT in .env (18473 when it is unset), with Studio at /studio/. For HTTPS on your own domain, see step 5: the gateway serves it itself, with no reverse proxy.

Images come from Docker Hub, and each CLI release runs the exact images it was tested with, never :latest: supatype/studio, supatype/storage, supatype/realtime, supatype/functions-worker and supatype/control-plane at the CLI’s own version, and supatype/schema-engine, supatype/server and supatype/postgres at the releases pinned for it. The stack also runs postgrest/postgrest, kong and SeaweedFS, and Valkey when the cache does not run inside Postgres. Upgrading the CLI moves them; supatype update pulls the new tags. To run another image, set its SUPATYPE_*_IMAGE in .env (for example SUPATYPE_SERVER_IMAGE=supatype/server:v2.3.0), or pin versions.engine, versions.server or versions.postgres in supatype.config.ts.

To run on a Postgres you already have, such as RDS or Cloud SQL, set database: { external: { url: process.env.DATABASE_URL! } } in supatype.config.ts. The stack then starts no db service, and every service connects there. It needs Postgres 17 or later. Field-level access rules are enforced through generated views instead of the planner rewrite in supatype/postgres. Realtime needs wal_level = logical, a free replication slot, the wal2json plugin and a role with REPLICATION. supatype db check --connection "$DATABASE_URL" reports what a database lacks, and --emit prints the SQL that fixes what it can.

Every function is handed two addresses. ctx.url is for calling the API from inside the function. Under Docker it is http://kong:8100, which no browser can open. ctx.publicUrl is the project’s public address, API_EXTERNAL_URL in .env, for links you give to people.

Functions get no database connection by default. Setting SUPATYPE_FUNCTIONS_DB_URL in .env hands every function that URL as ctx.dbUrl: a raw Postgres connection as whichever role it names. Row rules and field masking apply for that role exactly as they would for a request: a superuser or a role with BYPASSRLS (the admin role, service_role) skips both, any other role is held to them. Point it at a least-privilege login role that is neither, granted only what your functions need, never the admin URL, for example postgresql://functions_reader:<password>@db:5432/<POSTGRES_DB>. The database is the value of POSTGRES_DB in your .env (supatype init sets it to the project name; the stack default is supatype).

4. Serve a static app

Terminal window
$ supatype app add --static ./public

This writes app.mode: "static" to supatype.config.ts. Commit it. It is a one-time step, not something to repeat on the server.

On the server, build the app with supatype build rather than npm run build. It runs the same build script with the API URL and anon key from .env, and stops before building when either is missing. Deploy your frontend covers building on other hosts.

5. Turn on HTTPS

Point an A record for your domain at the server and open ports 80 and 443. Then:

Terminal window
$ supatype add domain example.com --email you@example.com
$ supatype self-host compose up -d

add domain sets server.mode: "standalone", server.domain and server.tls in supatype.config.ts. Commit it. On the next compose up the gateway listens on ports 80 and 443 instead of SUPATYPE_KONG_PORT, and gets and renews a Let’s Encrypt certificate for the domain itself, accepting Let’s Encrypt’s terms under the email you gave. The app, the APIs and Studio all share the one domain.

Set API_EXTERNAL_URL and SITE_URL in .env to https://example.com: values in .env win over the HTTPS default. Certificates are kept in the stack’s key-value store (the valkey-data volume, or the database when the cache is pg_keyspace), so they survive restarts. Port 80 also still answers plain HTTP: nothing redirects it to HTTPS.

supatype dev never turns HTTPS on, so the same committed config still runs on http://localhost.

Deploy changes

Local and self-hosted environments read the same committed config. What differs between machines lives in files you do not commit.

Which file holds what

FileHoldsCommit
supatype.config.tsSchema path, app routing, version pinsYes
supatype.local.config.tsOverrides for your machine, such as the dev proxyNo
supatype/renames.jsonRenames recorded with supatype renameYes
.envDATABASE_URL, JWT keys, API_EXTERNAL_URLNo

What to run when something changes

ChangeLocalSelf-hosted
Schemasupatype pushsupatype push
FrontendNothing with the dev proxy. Otherwise npm run buildsupatype build, then compose up -d
supatype.config.tsRestart supatype devcompose up -d
.envRestart supatype devcompose up -d, or compose restart <service> for one service

A typical server deploy

Terminal window
$ cd my-app
$ git pull
$ npm install # if package.json changed
$ supatype push # schema migrations
$ supatype build # the build script, with .env's API URL and anon key
$ supatype self-host compose up -d

Upgrading Supatype

Moving to newer Supatype components is separate from deploying your own changes. It takes four commands.

Terminal window
$ npm install -g @supatype/cli@latest # or supatype self-update
$ supatype update # pull the new images
$ supatype self-host compose up -d # run them
$ supatype push # apply the schema they expect

supatype update never updates the CLI itself, so update it first. The image pins come from the CLI version, so under Docker it looks up the latest CLI release and, when yours is behind, prints the upgrade command for how you installed it before carrying on. supatype update --check reports the running and latest versions without pulling, and the check is skipped with a warning when offline or on a CLI built from source. Under Docker, update renders the compose file and pulls the images. It does not restart anything, which is why compose up -d follows.

The push is the step that is easy to miss. Grants, policies, functions and buckets are generated from your schema and only reach the database through push, so new images on an older database can refuse rules until it runs. The upgrade is finished after the push, not before.

Running in production

A self-hosted stack is a Compose project, so you run it with the CLI and standard Postgres tools. Run these in the project directory on the server.

Health and logs

Terminal window
$ supatype status # each service and whether it is running
$ supatype self-host compose status # Compose's own view, with health
$ supatype logs --service server --since 1h
$ supatype self-host compose logs # every service, followed

supatype logs shows up to 100 lines per service from the past 5 minutes (--since changes that), then keeps following until you press Ctrl+C. Ask for a service that does not exist and it lists the ones that do. Postgres has a health check, and the services that use it wait until it passes.

Backups

There is no backup command for a Compose stack. Use pg_dump 17 or later on the server, against DATABASE_URL from .env, which reaches the Compose Postgres on 127.0.0.1. The dump holds every schema, including auth users, storage metadata and migration history.

Terminal window
$ export DATABASE_URL="$(grep '^DATABASE_URL=' .env | cut -d= -f2-)"
$ pg_dump -Fc -f backup-$(date +%F).dump "$DATABASE_URL"
$ pg_restore --clean --if-exists -d "$DATABASE_URL" backup-2026-10-28.dump

Stored files are not in the database. With the built-in storage they live in the storage-data volume, named supatype-<project>_storage-data in docker volume ls. Back that up with your usual volume tooling. supatype self-host compose down keeps both volumes, and only down --volumes deletes them.

Roll back a bad push

Terminal window
$ supatype migrations list # what was applied, when and by whom
$ supatype rollback # undo the last applied migration

rollback runs the reverse SQL stored with the last migration in one transaction and marks it rolled back. It then offers to restore your schema files from the snapshot stored with the migration before it, so the next push does not apply the change again. Pass --sync-schema to restore without asking, or --no-sync-schema to revert the database only. Commit the restored files.