Skip to main content

Overview

The trail CLI is the main entry point for managing TrailBase. It provides commands for running the server, managing users, handling migrations, working with WASM components, and more.

Global Options

These options are available for all commands:
string
default:"./traildepot"
Directory for runtime files including the database. Will be created by TrailBase if it doesn’t exist.Environment variable: DATA_DIR
string
Public URL used to access TrailBase. This is necessary for sending valid auth emails and OAuth2 redirects after users authenticate externally.Environment variable: PUBLIC_URL
boolean
Print trail version information including git version tag, commit date, and SQLite version.

Commands

run

Starts the HTTP server.
string
default:"localhost:4000"
Authority (<host>:<port>) the HTTP server binds to.Environment variable: ADDRESS
string
When set, UI and admin APIs will be served separately on this address.Environment variable: ADMIN_ADDRESS
string
Optional path to static assets that will be served at the HTTP root.Environment variable: PUBLIC_DIR
boolean
default:"false"
Enable SPA fallback: serve index.html for routes (paths without file extensions). File requests (e.g., /favicon.ico) will still return 404 if not found. Use with --public-dir.Environment variable: SPA
string
Optional path to sandboxed filesystem root for WASM runtime.Environment variable: RUNTIME_ROOT_FS
string
Optional path to MaxMindDB GeoIP database. Can be used to map logged IPs to a geo location.Environment variable: GEOIP_DB_PATH
boolean
Use permissive CORS and cookies to allow for cross-origin requests when developing the UI using externally hosted UI (e.g., using a dev server).
boolean
In demo mode, PII will be redacted from the logs.
boolean
default:"false"
Enable logging to stderr.
string[]
default:"*"
Limit the set of allowed origins the HTTP server will answer to.
number
Number of JavaScript isolates/workers to start. Defaults to the number of CPUs.Environment variable: RUNTIME_THREADS

schema

Export JSON Schema definitions for a table/API.
string
required
Name of the table to infer the JSON Schema from.
enum
Use-case for the type that determines which columns/fields will be required.Values:
  • insert - Insert mode (default)
  • select - Read/Select mode
  • update - Update mode
Environment variable: MODE

openapi

Export or serve OpenAPI definitions.

openapi print

Prints OpenAPI specification to stdout.
This outputs the complete OpenAPI 3.0 specification in JSON format.

openapi run

Requires the swagger feature to be enabled at compile time.
Runs a local Swagger UI server.
string
default:"localhost:4004"
Authority (<host>:<port>) the HTTP server binds to.Environment variable: ADDRESS
Example

migration

Creates a new empty migration file.
string
Optional suffix used for the generated migration file: U<timestamp>__<suffix>.sqlIf not provided, defaults to “update”.
string
Optional database name. If not provided, defaults to “main”.
Migration files are created with format U<timestamp>__<suffix>.sql where the timestamp ensures uniqueness and ordering.

admin

Manage admin users (list, demote, promote).

admin list

Lists all admin users.
Example output:

admin promote

Promotes a user to admin.
string
required
User identifier, either email address or UUID.
Example

admin demote

Demotes an admin user to normal user.
string
required
User identifier, either email address or UUID.
Example

user

Manage users. Unlike the admin UI, this will also let you change admin users.

user add

Adds a new and verified user.
string
required
Email address of the new user.
string
required
Password for the new user. Not checked against password policies.
Example

user delete

Delete a user.
string
required
User identifier, either email address or UUID.
This operation is irreversible. All user data will be permanently deleted.
Example

user change-password

Change a user’s password.
string
required
User identifier, either email address or UUID.
string
required
New password to set for the user.
Example

user change-email

Change a user’s email address.
string
required
User identifier, either email address or UUID.
string
required
New email address to set for the user.
Example

user verify

Change a user’s verification state.
string
required
User identifier, either email address or UUID.
boolean
default:"true"
User’s verification state to set.

user invalidate-session

Invalidate user sessions, requiring them to re-authenticate when their auth token expires.
string
required
User identifier, either email address or UUID.
Example

user mint-token

Mint an auth token for the given user.
string
required
User identifier, either email address or UUID.
Example output:
The output is in Bearer token format and can be used directly in Authorization headers.

user import

Import users from external sources.
string
Path to Auth0 exported users as ND JSON file.
boolean
default:"false"
In dry-run mode, users will only be validated and not imported.

email

Programmatically send emails using the configured email provider.
string
required
Receiver address (e.g., foo@bar.baz).Environment variable: TO
string
required
Subject line of the email to be sent.Environment variable: SUBJECT
string
required
Email body, i.e., the actual message.Environment variable: BODY
Requires email configuration in config.textproto or will fall back to the system’s sendmail.
Example

components

Manage WASM components.

components add

Add a new WASM component.
string
required
Component reference, which can be:
  • Name: First-party component name (e.g., trailbase/auth_ui)
  • URL: HTTPS URL to a .wasm or .zip file
  • Path: Local filesystem path to a .wasm or .zip file
Components are installed to <data-dir>/wasm/ directory.

components remove

Remove/delete a WASM component.
string
required
Component reference: name or local path. URLs are not supported for removal.
This permanently deletes the component files from disk.

components list

List available first-party components.
Example output:

components installed

List installed components with their interfaces.
Example output:

components update

Update all installed first-party components.
This command checks all installed components and updates those that are first-party components from the official registry.
Example Output

Exit Codes

  • 0: Success
  • Non-zero: Error occurred (error message will be logged)

Environment Variables

Most CLI options can be set via environment variables. The naming convention is:
  • Use SCREAMING_SNAKE_CASE
  • Drop the -- prefix
  • Replace - with _
For example:
  • --data-dirDATA_DIR
  • --public-urlPUBLIC_URL
  • --admin-addressADMIN_ADDRESS

Common Workflows