Overview
Thetrail 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:Directory for runtime files including the database. Will be created by TrailBase if it doesn’t exist.Environment variable:
DATA_DIRPublic URL used to access TrailBase. This is necessary for sending valid auth emails and OAuth2 redirects after users authenticate externally.Environment variable:
PUBLIC_URLPrint
trail version information including git version tag, commit date, and SQLite version.Commands
run
Starts the HTTP server.Authority (
<host>:<port>) the HTTP server binds to.Environment variable: ADDRESSWhen set, UI and admin APIs will be served separately on this address.Environment variable:
ADMIN_ADDRESSOptional path to static assets that will be served at the HTTP root.Environment variable:
PUBLIC_DIREnable 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: SPAOptional path to sandboxed filesystem root for WASM runtime.Environment variable:
RUNTIME_ROOT_FSOptional path to MaxMindDB GeoIP database. Can be used to map logged IPs to a geo location.Environment variable:
GEOIP_DB_PATHUse permissive CORS and cookies to allow for cross-origin requests when developing the UI using externally hosted UI (e.g., using a dev server).
In demo mode, PII will be redacted from the logs.
Enable logging to stderr.
Limit the set of allowed origins the HTTP server will answer to.
Number of JavaScript isolates/workers to start. Defaults to the number of CPUs.Environment variable:
RUNTIME_THREADSschema
Export JSON Schema definitions for a table/API.Name of the table to infer the JSON Schema from.
Use-case for the type that determines which columns/fields will be required.Values:
insert- Insert mode (default)select- Read/Select modeupdate- Update mode
MODEopenapi
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.Authority (
<host>:<port>) the HTTP server binds to.Environment variable: ADDRESSExample
migration
Creates a new empty migration file.Optional suffix used for the generated migration file:
U<timestamp>__<suffix>.sqlIf not provided, defaults to “update”.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.admin promote
Promotes a user to admin.User identifier, either email address or UUID.
Example
admin demote
Demotes an admin user to normal user.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.Email address of the new user.
Password for the new user. Not checked against password policies.
Example
user delete
Delete a user.User identifier, either email address or UUID.
Example
user change-password
Change a user’s password.User identifier, either email address or UUID.
New password to set for the user.
Example
user change-email
Change a user’s email address.User identifier, either email address or UUID.
New email address to set for the user.
Example
user verify
Change a user’s verification state.User identifier, either email address or UUID.
User’s verification state to set.
user invalidate-session
Invalidate user sessions, requiring them to re-authenticate when their auth token expires.User identifier, either email address or UUID.
Example
user mint-token
Mint an auth token for the given user.User identifier, either email address or UUID.
The output is in Bearer token format and can be used directly in Authorization headers.
user import
Import users from external sources.Path to Auth0 exported users as ND JSON file.
In dry-run mode, users will only be validated and not imported.
Receiver address (e.g.,
[email protected]).Environment variable: TOSubject line of the email to be sent.Environment variable:
SUBJECTEmail body, i.e., the actual message.Environment variable:
BODYRequires 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.Component reference, which can be:
- Name: First-party component name (e.g.,
trailbase/auth_ui) - URL: HTTPS URL to a
.wasmor.zipfile - Path: Local filesystem path to a
.wasmor.zipfile
Components are installed to
<data-dir>/wasm/ directory.components remove
Remove/delete a WASM component.Component reference: name or local path. URLs are not supported for removal.
components list
List available first-party components.components installed
List installed components with their interfaces.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_
--data-dir→DATA_DIR--public-url→PUBLIC_URL--admin-address→ADMIN_ADDRESS
Common Workflows
Start TrailBase for the first time
Start TrailBase for the first time
Create your first admin user
Create your first admin user
Create and apply a database migration
Create and apply a database migration
Install a WASM component
Install a WASM component