Skip to content

Configuration

A self-hosted stack reads its settings from two places: supatype.config.ts, and .env in the project root. Every supatype self-host compose command renders .supatype/self-host/docker-compose.yml from both, and Compose substitutes the .env values into it. Most containers see only the variables the generated file names. The one exception is the server container: it mounts the project at /project and loads .env itself, without overriding a value Compose already set, so an auth server setting such as SUPATYPE_EXTERNAL_ANONYMOUS_USERS_ENABLED also takes effect there. The services’ internal settings (ports between containers, PostgREST’s roles, the object store’s credentials) are fixed in the generated file.

Variables marked Required have no default: Compose stops before starting anything and names the one that is missing, for example POSTGRES_PASSWORD is missing from .env.

The managed block in .env

Some lines in .env are written by the CLI from supatype.config.ts, each under a comment that starts # supatype:managed. On a self-hosted stack these are the mailer settings that email in the config gives.

  • Do not edit a line under that marker. Every self-host compose up (and the other commands that start the stack) rewrites it from supatype.config.ts. A hand edit made in place, under the marker, is replaced too, and the CLI warns about it: it keeps a hash of each value it last wrote in .supatype/env-managed.json (never the value), and a line that no longer matches is a hand edit. A project with no such record yet, on the first run after an upgrade, gets no warning.
  • A line outside the block is warned about, then replaced if the config sets that name. Put your own value below the managed block, not under the marker. If it conflicts with what the config gives, the CLI prints a warning naming the key with its old and new value, then writes the config’s value in its place. To keep a value for a managed name, set it in supatype.config.ts.
  • A marked line for a name the config no longer gives is removed; a value outside the block for a name the config does not set is left alone.

The warning is only for a value that differs from the config’s and is not blank. A value that changed because you changed supatype.config.ts is not a hand edit and gets no warning.

Database

VariableDefaultDescription
POSTGRES_PASSWORDNoneRequired. Password of the database’s superuser, for direct SQL access
POSTGRES_USERsupatype_adminThe superuser. The bundled supatype/postgres image runs as supatype_admin, and the CLI refuses any other value
POSTGRES_DBsupatypeDatabase name. supatype init sets it to the project name
AUTHENTICATOR_PASSWORDNoneRequired. Password of authenticator, the role PostgREST connects as. Keep it different from POSTGRES_PASSWORD, so rotating yours does not take the REST API down
SUPATYPE_SQL_EDITOR_PASSWORDNoneRequired. Password of supatype_sql_editor, the role Studio’s SQL editor connects as. It is not a superuser
DATABASE_URLNoneThe connection string the CLI uses from the host. With database.external every service uses it too, and it becomes required
SUPATYPE_DB_PORT5432Host port the database is published on
SUPATYPE_DB_PUBLIC_HOSTserver.domain, else 127.0.0.1Host name Studio shows in the database’s connection strings
SUPATYPE_DB_POOLER_URLNoneA connection pooler’s URL, for Studio to show beside the direct one
SUPATYPE_ALLOW_SECRET_READBACKfalseLets Studio reveal the database password through the server’s admin routes

supatype init generates POSTGRES_PASSWORD, AUTHENTICATOR_PASSWORD and SUPATYPE_SQL_EDITOR_PASSWORD for a new project.

Keys and secrets

VariableDefaultDescription
JWT_SECRETNoneRequired. Signs every token. At least 32 characters: see JWT secret length
ANON_KEYNoneThe public API key, a JWT signed with JWT_SECRET. supatype self-host compose up mints it when it is blank
SERVICE_ROLE_KEYNoneThe admin API key, minted the same way. Required by the control plane
SUPATYPE_CONTROL_PLANE_SECRETGeneratedShared by the API server and the control plane only. Every self-host compose command writes one into .env when it is missing
SUPATYPE_MCP_GATEWAY_KEYGeneratedShared by the API server and the MCP service only. The server accepts an MCP client’s token only on a call the MCP proved with it, so the token works nowhere but the MCP. Generated the same way
SUPATYPE_KEYSPACE_PASSWORDGeneratedThe cache’s password, required when the cache runs inside Postgres on supatype/postgres 17.2.13 or later. Generated the same way. See Cache

Access tokens expire after 3600 seconds. The generated file fixes this value; .env does not change it.

JWT secret length

PostgREST refuses to start with a JWT secret shorter than 32 characters, and everything else in the stack accepts one, so a short secret used to bring the stack up whole except for the REST API. The CLI now checks first: supatype dev and supatype self-host compose up stop before starting anything when JWT_SECRET is too short, with:

JWT_SECRET in .env is 20 characters, and the REST API needs at least 32.

Generate a longer one, for example with openssl rand -base64 48, put it in .env as JWT_SECRET, then run supatype keys --write --force to sign ANON_KEY and SERVICE_ROLE_KEY with it. Without --force, --write only fills keys that are blank and leaves keys signed with the old secret in place.

Public URLs and ports

VariableDefaultDescription
API_EXTERNAL_URLhttp://localhost:18473, or https://<server.domain> with TLS onThe API’s public address. Emailed links, OAuth redirect URIs and ctx.publicUrl in functions are built from it
SITE_URLhttp://localhost:3000, or https://<server.domain> with TLS onYour application’s URL, for auth redirects. Its origin is always allowed by CORS
SUPATYPE_KONG_PORT18473Host port of the gateway. With TLS on, the gateway publishes ports 80 and 443 instead
SUPATYPE_SERVER_PORT9999Host port of the API server itself, behind the gateway
SUPATYPE_SEAWEEDFS_PORT8333Host port of the object store behind storage. Unused with storage.production: "s3", which runs none (Storage)
SUPATYPE_PUBLISH_ADDRESS127.0.0.1Address the database, the API server and the object store are published on. Loopback keeps them off the network; the gateway is the way in

TLS is on when supatype.config.ts sets server.mode: "standalone", a server.domain and server.tls.email. See Docker setup.

Authentication

VariableDefaultDescription
DISABLE_SIGNUPfalseRefuse new sign-ups
SUPATYPE_EXTERNAL_EMAIL_ENABLEDtrue, or false when auth.email.enabled is falseEmail-and-password sign-up and sign-in, with magic links and password recovery
SUPATYPE_MAILER_AUTOCONFIRMfalse, or true when auth.email.enableConfirmations is falseConfirm new email addresses without sending a confirmation email

The defaults come from auth.email in supatype.config.ts, and either variable set in .env wins over the config (restart the stack after changing it). The CLI never writes them into .env; a SUPATYPE_MAILER_AUTOCONFIRM line an earlier CLI wrote there is taken out on the next start, with a message saying so. A self-hosted stack sends a confirmation link with every new email sign-up unless one of them says otherwise, so configure email delivery (below) before you open sign-up. Local dev confirms sign-ups at once unless the config says otherwise.

Email

Set email delivery in the email block of supatype.config.ts. Every self-host compose command writes these .env variables from it, so the config is the one place to change them:

supatype.config.ts key.env variableDefaultDescription
email.providerSUPATYPE_MAILER_MAILER_PROVIDERconsoleconsole writes each message to the server’s log and sends nothing. Set smtp to deliver through the server below
email.smtp.hostSUPATYPE_SMTP_HOSTNoneSMTP server hostname
email.smtp.portSUPATYPE_SMTP_PORT587SMTP server port
email.smtp.userSUPATYPE_SMTP_USERNoneSMTP username
email.smtp.passSUPATYPE_SMTP_PASSNoneSMTP password
email.smtp.admin_emailSUPATYPE_SMTP_ADMIN_EMAILNoneThe address messages are sent from
email.smtp.sender_nameSUPATYPE_SMTP_SENDER_NAMENoneThe name shown beside that address
supatype.config.ts
email: {
provider: "smtp",
smtp: { host: "smtp.example.com", port: 587, user: "apikey", pass: process.env.SMTP_PASS, admin_email: "no-reply@example.com" },
},

Do not set SUPATYPE_MAILER_MAILER_PROVIDER in .env: the next self-host compose command replaces it with the config’s value, console when the config has no email, and prints a warning naming the key with its old and new value (a password or key is shown as ***). This holds for a value outside the managed block and for one edited in place under the marker. With the console provider no email leaves the server, whatever the SMTP variables say. The generated file passes only these settings, so on a self-hosted stack use console or smtp.

OAuth providers

Declare providers under auth.providers in supatype.config.ts. The compose file turns each one into the SUPATYPE_EXTERNAL_<PROVIDER>_* variables the auth server reads, and fills in the redirect URI as API_EXTERNAL_URL followed by /auth/v1/callback:

// docs:no-check (a fragment: the rest of your config stays as it is)
import { defineConfig, env } from "@supatype/cli"
export default defineConfig({
auth: {
providers: {
github: { clientId: "Iv1.0123456789abcdef", secret: env("GITHUB_SECRET") },
},
},
})

The secret is the name of a variable in .env, never the value. For each declared provider, a SUPATYPE_EXTERNAL_<PROVIDER>_<SETTING> variable in .env (_ENABLED, _CLIENT_ID, _SECRET, _REDIRECT_URI, _URL, _SKIP_NONCE_CHECK, _EMAIL_OPTIONAL) overrides what the config gives. A provider that is not under auth.providers does not reach the server, even when its variables are in .env. See OAuth providers.

Allowed browser origins (CORS)

Outside dev mode the server’s gateway decides CORS for every service behind it. The browser origins it allows by default are:

  1. the origin of SITE_URL,
  2. the origins in api.corsOrigins in supatype.config.ts,
  3. the origins in SUPATYPE_CORS_ALLOW_ORIGINS in .env (comma-separated).
supatype.config.ts
// docs:no-check (a fragment: the rest of your config stays as it is)
import { defineConfig } from "@supatype/cli"
export default defineConfig({
project: { name: "my-project" },
server: { mode: "standalone" },
api: { corsOrigins: ["https://admin.example.com", "http://localhost:5173"] },
})

Each api.corsOrigins entry is scheme://host[:port] with an http or https scheme, or *. Anything else (a path, a query, another scheme) stops the config from loading with api.corsOrigins must be an array of origins (scheme://host[:port]) or "*". The generated compose file passes the config’s origins to the server ahead of SUPATYPE_CORS_ALLOW_ORIGINS, so re-render it (any supatype self-host compose command does) after changing them.

Owners, admins and developers can also change the list in Studio, on the Settings > CORS tab, which shows each origin and where it comes from. A list saved there is kept in the project’s database (auth.cors_origins), survives a restart, reaches every server replica within ten seconds, and replaces the default until someone presses Reset to default. Viewers can read it.

Site URLAlways allowed, whatever list is saved
Any other originRefused: a preflight gets 403, and other responses carry no CORS headers
*Allows every origin, and only when you write it in one of the places above. It is never a default
Dev modeUnchanged: supatype dev allows every origin, whatever the list says

Before this, a standalone server with no SUPATYPE_CORS_ALLOW_ORIGINS allowed every origin. If a production web app on another origin calls your API, add its origin before upgrading.

Cache

The API server’s response cache, and the gateway’s certificates once HTTPS is on, are kept in a keyspace that speaks the Redis protocol (RESP). It is pg_keyspace inside the db container, unless cache.provider in supatype.config.ts is "valkey", the database is external, or the Postgres image is older than 17.2.9: then the stack runs a Valkey service instead.

VariableDefaultDescription
SUPATYPE_KEYSPACE_PASSWORDGeneratedRequired when the cache is pg_keyspace on supatype/postgres 17.2.13 or later. The password of the keyspace user supatype, handed to the db and server services, and to kong when HTTPS is on
SUPATYPE_KEYSPACE_PASSWORD_FILENoneA file on the host holding that password, in place of the variable. Mounted into db and server; not with HTTPS on. See Passwords from files
SUPATYPE_PROJECT_KEYSPACE_ADDRThe stack’s keyspacehost:port of a second keyspace for the response cache alone. Unset, the response cache uses the stack’s keyspace
SUPATYPE_PROJECT_KEYSPACE_USERNAMEsupatypeThe user the server logs in to that second keyspace as
SUPATYPE_PROJECT_KEYSPACE_PASSWORDNoneThe second keyspace’s password. Unset, the server sends it no password. It never falls back to SUPATYPE_KEYSPACE_PASSWORD, and the server refuses to start when the two are the same

supatype init writes a random SUPATYPE_KEYSPACE_PASSWORD into .env. Every self-host compose command, and supatype dev, writes one when it is missing, and never replaces one that is there. With the password in a file instead, none is written: see Passwords from files. The compose file requires it, so docker compose run by hand without it stops with SUPATYPE_KEYSPACE_PASSWORD is missing from .env. A Valkey service has no password: it is reachable on the compose network only.

To change the password, put the new one in .env and run supatype self-host compose up -d. Compose recreates every service that receives it, so each starts with the new password. The cache starts empty, which costs nothing but a few cache misses; the gateway’s certificates are kept.

The three project keyspace variables are for a deployment that keeps cached responses in a keyspace of their own, apart from the one holding the stack’s shared state. The server reads them from .env itself, so they need no change to the compose file. SUPATYPE_PROJECT_KEYSPACE_PASSWORD must differ from SUPATYPE_KEYSPACE_PASSWORD, or the server stops at start with config: SUPATYPE_PROJECT_KEYSPACE_PASSWORD must differ from SUPATYPE_KEYSPACE_PASSWORD.

Passwords from files

Running the server or the supatype/postgres image yourself, you can give each password as a file instead, the way POSTGRES_PASSWORD_FILE works for a Docker or Kubernetes secret: SUPATYPE_KEYSPACE_PASSWORD_FILE (read by both the server and the image) and SUPATYPE_PROJECT_KEYSPACE_PASSWORD_FILE (read by the server). One trailing newline is dropped, and nothing else. Setting a password and its file together, or naming a file that is missing or empty, stops the service at start with a message naming the variable or the file.

With the file, the database takes a new password with no restart: rewrite the file, then run SELECT pg_reload_conf(); in the database. The old password stops working at once. The server reads its password when it starts, so restart it with the new one.

The stack the CLI generates (supatype dev with Docker, and self-host compose) takes the file too. Set SUPATYPE_KEYSPACE_PASSWORD_FILE in .env or in the shell to a file on the host, either absolute or relative to the project directory:

Terminal window
SUPATYPE_KEYSPACE_PASSWORD_FILE=./secrets/keyspace-password

The CLI then writes no SUPATYPE_KEYSPACE_PASSWORD, and the compose file mounts that file read-only into db and server at /run/secrets/supatype-keyspace-password and gives both that path in SUPATYPE_KEYSPACE_PASSWORD_FILE instead of the password. Before compose runs, the CLI stops with a message when:

  • both SUPATYPE_KEYSPACE_PASSWORD and SUPATYPE_KEYSPACE_PASSWORD_FILE are set, saying where each is set. A project that ran before has a generated password in .env: remove that line to use the file. The CLI never removes it for you.
  • the file is missing, cannot be read, or holds no password.
  • HTTPS is on (server.tls). Kong keeps its certificates in the keyspace and gets the password through its env vault, which reads environment variables only, so it cannot use a file. Keep the password in .env for an HTTPS stack.

On a Linux host the containers see the file with its host owner and mode, and the database reads it as the image’s postgres user, so make it readable to them (mode 0644 or 0444). A single file mounted this way stays the file that was there when the container started: rewrite it in place to change the password, since an editor that saves a new file in its place leaves the containers with the old one until they restart.

supatype init run with SUPATYPE_KEYSPACE_PASSWORD_FILE set in the shell writes a comment in place of the generated password. Native supatype dev reads the password from the file as well, and hands it to its Postgres and server itself.

Storage

By default the stack runs a SeaweedFS service for uploaded files, in the storage-data volume, and the storage service gives each bucket an S3 bucket of its own there. The compose file passes the storage service every S3 setting for it, so there is nothing to set.

To keep production files in an S3 bucket of your own instead, set storage.production in supatype.config.ts (supatype init writes it when you answer “Production storage?” with S3):

storage: { provider: "local", local_path: ".supatype/storage", production: "s3" },

The stack then leaves SeaweedFS and its volume out, and runs the storage service in single-bucket mode: every bucket is a key prefix inside S3_BUCKET, and public files are served by the storage service, so the S3 bucket stays private. storage.provider is unaffected: it is where supatype dev keeps files, and the Docker dev stack keeps its SeaweedFS either way.

VariableDefaultDescription
S3_BUCKETNone, requiredThe bucket. self-host compose up stops with a message while it is blank
S3_REGIONNoneThe bucket’s region. Required on AWS, where S3_ENDPOINT stays blank
S3_ENDPOINTNoneThe store’s URL, for an S3-compatible store such as Cloudflare R2. The storage service runs in a container, where localhost is that container: for a store on the same machine use http://host.docker.internal:<port> with Docker Desktop, or the host’s address (usually 172.17.0.1) on Linux
S3_ACCESS_KEY, S3_SECRET_KEYNoneKeys that can read, write, list and delete objects in the bucket. Leave both blank on AWS to use the instance’s or task’s role
S3_FORCE_PATH_STYLEtrue with an endpoint, false withoutWhether the bucket goes in the URL path rather than the host name

Set these in the server’s .env, and use a different bucket from the one supatype dev uses. Switching an existing stack to production: "s3" does not move its files out of SeaweedFS. See Storage for the bucket’s layout, and for S3_BUCKET_PREFIX when you run the storage service yourself with one S3 bucket per bucket.

Functions

VariableDefaultDescription
SUPATYPE_FUNCTIONS_DB_URLNoneA Postgres URL handed to every function as ctx.dbUrl. Rules and masking apply for the role the URL names; a superuser or BYPASSRLS role (the admin role, service_role) skips both. Name a least-privilege login role, never the admin URL, and end the URL with the database in POSTGRES_DB
STRIPE_SECRET_KEYNonePassed to the functions worker
STRIPE_WEBHOOK_SECRETNonePassed to the functions worker

Realtime

VariableDefaultDescription
REALTIME_LOG_LEVELinfodebug also logs each change a subscriber’s access rules withheld

Realtime runs unless database.external.realtime is false.

Images

Each service’s image can be replaced from .env: SUPATYPE_POSTGRES_IMAGE, SUPATYPE_SERVER_IMAGE, SUPATYPE_STORAGE_IMAGE, SUPATYPE_FUNCTIONS_WORKER_IMAGE, SUPATYPE_REALTIME_IMAGE, SUPATYPE_CONTROL_PLANE_IMAGE, SUPATYPE_STUDIO_IMAGE, SUPATYPE_ENGINE_IMAGE, SUPATYPE_SEAWEEDFS_IMAGE, SUPATYPE_VALKEY_IMAGE and SUPATYPE_KONG_IMAGE. Left unset, each service runs the image the generated file names: for Supatype’s own services, the exact release the CLI was tested with, never latest, so upgrading the CLI moves them. A versions pin for engine or server in supatype.config.ts writes SUPATYPE_ENGINE_IMAGE or SUPATYPE_SERVER_IMAGE into .env for you.

A versions pin wins over a hand-written image for the same service: the next self-host compose command puts the pinned image back and prints a warning naming the variable with its old and new value. To run your own image, remove that pin from supatype.config.ts.

Generating keys

supatype keys signs ANON_KEY and SERVICE_ROLE_KEY with the JWT_SECRET in .env (or the one you pass with --secret) and prints them:

Terminal window
npx @supatype/cli keys
FlagEffect
--writeWrite the keys into .env instead of printing them. Only blank keys are filled
--forceWith --write, replace keys that already hold a value
--exp-years <years>How long the keys are valid, in years. Default 10
--secret <secret>Sign with this secret instead of JWT_SECRET

The command does not create JWT_SECRET: supatype init generates one, or use openssl rand -base64 48. Use different secrets in every environment.