OneBase

CLI

onebase <command> [flags]
Command
serveRun the server
devRun the server, regenerate _generated/ and restart when files change; full error messages and index warnings
codegenWrite onebase/_generated/ (api.ts, server.ts, dataModel.ts)
doctorCheck the schema, functions, crons and imports for common mistakes; exits 1 on errors
deployPush functions (and public/) to a running server with no restart; --dry-run checks only, --rollback goes back one (see Deployment)
buildCompile functions and frontend into one executable
backupTake one SQLite snapshot to --backup now
backupsList snapshots in --backup
restoreRestore the newest snapshot (or --at) into --data
vacuumShrink the SQLite file to the data it holds; stop the server first (see vacuum)
versionPrint the version

#Flags

Each flag can also be set with an environment variable, which can come from a .env file.

FlagDefault
--dir <path>./onebase / $ONEBASE_DIRFunctions folder. A Convex project's ./convex folder is used if there's no ./onebase.
--data <path>./onebase_data / $ONEBASE_DATAData folder (SQLite database and local files)
--public <path>./public if present / $ONEBASE_PUBLICStatic frontend; unknown paths fall back to index.html. deploy ships it.
--port <n>8090 / $PORT
--host <addr>0.0.0.0 / $ONEBASE_HOST
--url <url>http://localhost:<port> / $ONEBASE_URLPublic URL, used in file URLs. For deploy: the server to push to ($ONEBASE_DEPLOY_URL).
--db <url><data>/db.sqlite / $ONEBASE_DB / $DATABASE_URLSQLite path, postgres://…, mysql://…, or libsql://… / https://…
--files <s3url>local <data>/files / $ONEBASE_FILESs3://bucket/prefix
--backup <s3url>/ $ONEBASE_BACKUPs3://bucket/prefix
--backup-every <d>1h / $ONEBASE_BACKUP_EVERY30m, 6h, 1d, …
--backup-keep <n>24 / $ONEBASE_BACKUP_KEEPSnapshots to keep
--at <time>newestrestore: pick a snapshot
--forcerestore: overwrite an existing database
--cors <origins>any / $ONEBASE_CORSBrowser origins allowed to call the API, comma-separated
--rate-limit <r>off / $ONEBASE_RATE_LIMITPer-IP limit on calls, subscriptions and uploads, e.g. 100/10s, 600/m
--trust-proxyoff / $ONEBASE_TRUST_PROXY=1Take the client IP from X-Forwarded-For
--no-dashboarddashboard on / $ONEBASE_DASHBOARD=offDon't serve the dashboard or admin API at /_admin (this also turns off deploys)
--no-deploydeploys on / $ONEBASE_DEPLOY=offRefuse onebase deploy and run the local code instead of what was pushed
--dry-rundeploy: check the code against the server's data without changing anything
--rollbackdeploy: go back to the previous deployment
--env-file <path>.env files for the commandRead only this file; repeat for several
--out <file>./appbuild: output file
--target <t>current platformbuild: bun-linux-x64, bun-linux-arm64, bun-darwin-arm64, bun-darwin-x64, bun-windows-x64

#Environment variables

S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_ENDPOINT, S3_REGIONS3 credentials for --files and --backup (AWS_* equivalents also work)
TURSO_AUTH_TOKEN / LIBSQL_AUTH_TOKENToken for --db libsql://…
ONEBASE_ADMIN_KEYDashboard and deploy key (default: generated into <data>/admin.key)
ONEBASE_DEPLOY_URL, ONEBASE_DEPLOY_KEYdeploy: the server, and its admin key. Keep them in .env.local.
ONEBASE_QUERY_TIMEOUT, ONEBASE_MUTATION_TIMEOUT, ONEBASE_ACTION_TIMEOUTHow long a call may run (default 10s, 10s, 10m; off for no limit). See Time limits.
ONEBASE_VECTOR_MEMORY_MBMemory for SQLite's vector indexes (default 2048; 0 to search them in SQL). See Vector search.
ONEBASE_VECTOR_WORKERSThreads for searching SQLite's vector indexes (default: up to 8, one less than the CPU cores; 0 for the main thread only)

#doctor

✗ error posts.ts:2: Imports from the convex package instead of onebase.
         fix: Use "./_generated/server" for query/mutation/action and "onebase/values" for v.
✗ error schema.ts › posts.index("by_athor"): Field "athor" doesn't exist on "posts".
         fix: Known fields: title, author
⚠ warn  posts.ts › add: mutation has no args validator, so any input is accepted.
         fix: Add args: { ... } (use args: {} if it takes none).

doctor checks:

  • files that fail to load
  • index fields that don't exist, and duplicate or reserved index names
  • v.id() pointing at missing tables
  • functions without args
  • crons that call missing functions
  • imports from convex/*
  • "use node"
  • .filter(doc => doc.x === …) mistakes
  • stale _generated/ files
  • a SQLite database (--db, or <data>/db.sqlite) where deleted documents left a lot of free space

#vacuum

SQLite doesn't shrink its file when documents are deleted: it keeps the free pages and reuses them for new writes. A database created by this version of onebase gives them back by itself. Every 5 minutes, once free pages are at least 64 MB and a quarter of the file, the server frees up to 256 MB, in small slices so writes keep going. The same pass cuts the WAL file back to nothing. Databases created by older versions can't do this until they've been vacuumed once:

onebase vacuum --data ./onebase_data

vacuum rewrites the whole file, so it needs about as much free disk as the data takes up. Writes wait while it runs, so stop the server first. onebase doctor tells you when it's worth running.