Skip to content

Getting started

Protobase is a config-driven admin panel framework for existing Postgres databases. Each resource’s data config lives in config/<resource>/data.ts and its UI config in ui.ts, all exported from config/index.ts; the rest of the app, its sign-in, jobs, files and API settings, is one object of data in protobase.config.ts. A Hono server serves the API and a React app renders the admin. Coding agents get the guides and reference of the installed version with protobase skill install.

An app’s own React code, its components, field types and actions, is a plugin: built on its own against a plugin API that Protobase’s releases keep, and loaded by the admin app when it starts. Protobase maintains the admin app, the API and the server, and a plugin keeps working as the app moves to newer releases, with their fixes and features, without changes of its own. Below 1.0 a new minor version may still change the config, and the bundle is built again for it; the plugins’ code stays as it is (see Who maintains what).

To see whether Protobase is of use before setting anything up, paste this line into the Run box (Win+R), a Command Prompt or PowerShell:

powershell -c "irm https://docs.protobase.net/try.ps1|iex"

It downloads protobase-try.exe from the latest release, about 75 MB, and PostgreSQL 18, about 40 MB, once, and starts the automations preset with workflows on, on this computer alone. It prints the address, http://localhost:3000 unless that port is taken, and an admin’s email and password, adds a sample workflow, “Say hello”, and opens the browser. Nothing is installed and nothing needs Git, Node or Bun: the program, the database and the app’s files stay in %LOCALAPPDATA%\Protobase\automations, with the password in sign-in.txt there. Ctrl+C or closing the window stops it; the line starts it again, and takes the newer program when a release is out. To remove everything, stop it and delete that folder. It is a trial of a finished app, not a project to change: Start an app makes one.

npm create protobase my-app asks which preset to start from, scratch (the default), automations (scratch with workflows on), the ERP, the property portal or real estate, writes the project into my-app, with the @protobase packages in devDependencies at the caret range of the latest release, so it is bundled: dev, the build and its scripts run the CLI’s own copies, and a newer CLI in that range updates it with no change to its files. It prints the next steps. Without a folder it asks for one too. --preset <name> picks the preset without asking; without a terminal it takes scratch. bun create protobase and pnpm create protobase do the same, and take --preset without the -- that npm needs. It needs Node 22.12 or later. Each preset has an AGENTS.md with the rules for a coding agent that changes the app, such as a new migration file for every schema change.

Terminal window
npm create protobase my-app
npm create protobase my-app -- --preset real-estate

The project comes with its own Postgres for development: a docker-compose.yml with Postgres 18, started by bun run db:up and stopped by bun run db:down, on port 55432 or, when something listens there already, the next free one. Its .env points at that database and has a PROTOBASE_SECRET of its own. Without Docker, set DATABASE_URL in .env to a Postgres database of yours. The next steps install it with Bun, which runs the project’s scripts, start the database, migrate it, load the preset’s base data, if it has any, create a user and run bun run dev. For scratch:

Terminal window
cd my-app
bun install
bun run db:up
bun run db:migrate
bun run protobase users create [email protected] --generate-password
bun run dev # prints its address, http://localhost:<port>

A scratch app starts without resources, so protobase doctor refuses it until it has one. A table comes in through a migration, the next file in db/migrations/, and scaffold writes its resource from the database:

Terminal window
# db/migrations/007_customers.sql: create table customers (id bigint generated always as identity primary key, name text not null);
bun run db:migrate
bun run protobase scaffold --ui --yes
bun run protobase doctor

scaffold writes config/customers/data.ts and ui.ts and exports them from config/index.ts, where Protobase finds every resource, view and page. bun run dev shows the new list at once. The Data config and UI config say what else a resource can be.

Given the URL of a Postgres database you already have, npm create protobase makes the project on that database:

Terminal window
npm create protobase 'postgres://user:password@localhost:5432/shop'
bun create protobase 'postgres://user:password@localhost:5432/shop'
pnpm create protobase 'postgres://user:password@localhost:5432/shop'

It connects read-only and names the database and its Postgres version, then asks for the folder, the database’s name by default (npm create protobase my-app <url> names it). It writes the scratch preset there, with the URL in .env, the URL without its password in .env.example, and no docker-compose.yml, and installs its packages with Bun, or with npm without Bun. It then lists the tables the project’s scaffold writes resources over, and what it leaves out, with why: views, tables without a primary key or a unique index on columns that are never null, and Protobase’s own tables. It asks:

  • which tables become resources: numbers, ranges such as 2-4 or names, separated by commas, all of them by default. The tables those point to through foreign keys come too, since a relation needs the resource of its table, and it names them;
  • whether each gets a ui.ts with its names and list, yes by default;
  • whether to review the field proposed for each column, as scaffold asks it, no by default.

Then it runs that scaffold in the project and prints the next steps. Without a terminal it asks nothing: the folder is the database’s name, and every table gets a resource and a ui.ts. Quote the URL, as a shell reads ? and & in it. --preset is refused with a URL: the project starts from scratch.

It never writes to the database. The first of the next steps does: bun run db:migrate adds the auth schema that sign-in keeps its users in, and the migrations schema, where the script records the migrations it applied in migrations.applied. A public.schema_migrations another migration tool keeps is left as it is.

Terminal window
cd shop
bun run db:migrate # the first write to the database
bun run protobase users create [email protected] --generate-password
bun run dev # prints its address, http://localhost:<port>

On a Supabase database, which it knows by its auth and storage schemas and its supabase_admin role, as import supabase does, the auth schema is Supabase Auth’s, and the project changes nothing in it. It leaves out auth, storage and the platform’s other schemas, such as realtime and supabase_migrations, as Supabase’s own tables. The project reads Supabase’s users through a view over auth.users and keeps only its own sign-in data, in a schema of its own, app_auth: it points protobase.config.ts at the view, with users.keyTable, and writes migrations in place of those of Protobase’s own user table: Better Auth’s tables in app_auth, pointing at auth.users, then the view, its side table of the columns only Better Auth has, and each user’s account with their Supabase password and social providers. bun run db:migrate applies them as the postgres role a Supabase connection string signs in as, and Supabase’s users sign in with their own passwords, under their own ids. You can create, disable and delete users from either side, and a name changed in Supabase shows at once. A user who signs up through Supabase Auth later is a user of the project at once but cannot sign in with a password because sharing passwords with Supabase Auth is not implemented. Supabase’s phone-only and anonymous users are not users of the project, since sign-in needs an email. A ban set in the project stays the project’s own, while a ban set in Supabase holds in the project too.

For a Postgres database you already have, npm create protobase <database-url> makes the project, as above. Admin over an existing database does it by hand, in a folder of your own: install the packages, scaffold the config from the tables, check it with doctor, add sign-in and its tables, create the first admin and run protobase dev.

Every page of these docs is also Markdown at its address plus .md: https://docs.protobase.net/reference/cli/ is also https://docs.protobase.net/reference/cli.md. The code a page shows from example files is written out in it, and its live demos are left out, so a coding agent or a chat assistant reads the page whole. In a project, protobase skill install gives coding agents the docs of the installed version.

A chat assistant starts from /llms.txt, which links every page’s Markdown and the protobase agent skill of the latest release at /skills/protobase/SKILL.md, with its references beside it.

The rest of this page works in a clone of this repository, on its example apps in tests/apps.

Requires Bun 1.4.4, which installs the repository and runs its scripts and tests, and Node 22.12 or later (.nvmrc) for the smoke test on Node.

Terminal window
bun install

tests/apps/erp is a sample ERP on a real Postgres database, seeded with three years of history. bun run db:up starts the Postgres container and gives each example its database and a .env from its .env.example. Without Docker, POSTGRES_RUNNER=local in the repository’s .env runs the machine’s own Postgres 18 and PgBouncer as plain processes on the same ports instead, with their data in .protobase/postgres; POSTGRES_BIN names the folder of initdb and pg_ctl when they are not on PATH. Supabase’s Postgres, which bun run test:record needs, runs only in Docker. The databases listen on 127.0.0.1 only, so on Docker Engine 28.0.0 or later other machines on the network cannot reach them, unless the daemon’s allow-direct-routing option, off by default, lets them reach containers by their own address; an older Docker Engine lets hosts on the same local network segment reach them, so it needs a firewall that blocks them. On Linux with firewalld, Docker Engine 28.2.0 to 28.3.2 lets other hosts reach them again after a firewalld reload, so it needs that firewall too, or an upgrade to 28.3.3 or later. A checkout or worktree on an older base publishes them on every interface again, so rebase it onto main before any docker compose up or db:up.

Terminal window
bun run db:up && bun run --cwd tests/apps/erp db:migrate && bun run --cwd tests/apps/erp db:seed --scale small # the ERP's tables and Better Auth's
bun run --cwd tests/apps/erp protobase users create [email protected] --generate-password
bun run --cwd tests/apps/erp dev # prints its address, http://localhost:<port>

PROTOBASE_SECRET in tests/apps/erp/.env signs the session cookies; see Login with Better Auth. protobase dev serves the admin app and the API on one port and reloads both on every change (CLI). Its startup message says how to sign in: while the database has no users, it prints the exact users create command for the first admin. Each example keeps a port of its own, picked on its first run, so they run side by side at addresses that stay the same; it stops with a clear message when another server holds that port, and --port <port> changes it.

tests/apps/real-estate is a rental and property management firm: owners, properties and units, leases and tenants, monthly rent, payments and arrears, and maintenance. Its database sits beside the ERP’s in the same Postgres container, and it keeps its own .env.

Terminal window
bun run db:up && bun run --cwd tests/apps/real-estate db:migrate && bun run --cwd tests/apps/real-estate db:seed --scale small
bun run --cwd tests/apps/real-estate protobase users create [email protected] --role admin --generate-password
bun run --cwd tests/apps/real-estate dev # prints its address, http://localhost:<port>

tests/apps/property-portal is a public portal of homes for sale and for rent in the Netherlands and Spain. Visitors browse and filter the listings without signing in, through the anonymous role; members save searches of the listings that mail them new homes, and keep favorites and notes that only they see. The seed makes two members, [email protected] and [email protected], and an admin, [email protected], all with the password property-portal-demo.

Terminal window
bun run db:up && bun run --cwd tests/apps/property-portal db:migrate && bun run --cwd tests/apps/property-portal db:seed --scale small
bun run --cwd tests/apps/property-portal dev # prints its address, http://localhost:<port>
Command Purpose
bun run db:up / bun run db:down start or stop the Postgres container, or with POSTGRES_RUNNER=local in .env the local Postgres and PgBouncer processes; db:up also creates the examples’ databases and .env files
bun run test the unit tests and the snapshot tests in packages/*/tests/ and tests/ (Vitest projects unit* and snapshot*): no Postgres server, subprocess or network. A snapshot test replays the SQL recorded for it from Postgres in <test>.sql.json
bun run test:record runs the snapshot tests on the Postgres container instead and writes their recordings, after building their templates (bun run test:db snapshots); run it when a change makes a snapshot test fail with stale snapshot
bun run test:unit only the unit tests, next to the code (Vitest projects unit, whose files share their modules, and unit-isolated, for those that mock a module or change a global), fully parallel; starting a Postgres client there throws
bun run test:watch bun run test in watch mode
bun run test:integration the database, subprocess and build tests (projects integration*), against the Postgres container, among them the real-Postgres tests (*.postgres.test.ts)
bun run test:smoke / node --run test:smoke the CLI on Bun or on Node builds the ERP and serves its bundle, whose € must come back intact; part of test:integration on Bun
bun run presets:write <version> <dir> writes each preset to <dir>/<name>: a standalone copy of its example with the @protobase packages in devDependencies, bundled, in the caret range of <version> (^x.y.z, which below 1.0 covers only that minor) and its own bun.lock at exactly <version>, which must be on npm
bun run images:context the build contexts of the protobase and protobase-dev images in dist/images, at the version in package.json (see Deploy)
bun run test:presets writes each preset as bun run presets:write does it and installs it with Bun from npm (so at a published version), then migrates, seeds, checks, tests and builds it on a database of its own, as a role without superuser rights; needs the Postgres container
bun run test:postgres the Postgres suite in tests/postgres/ (Vitest project postgres): the ERP’s medium seed and the planner’s statistics on it, and the jobs and event delivery through PgBouncer; needs the Postgres and PgBouncer containers and bun run test:db postgres
bun run test:db builds the template databases the database tests clone for each run (protobase_test_template, real_estate_test_template, property_portal_test_template, all at small scale, and the empty, auth and jobs snapshot_*_test_template the real-Postgres and end-to-end tests clone), when missing or older than what they are built from; without them those tests skip. bun run test:db postgres builds the Postgres suite’s (protobase_medium_test_template, the ERP at medium scale), bun run test:db snapshots the ones test:record records on (snapshot_*_test_template). Tests never use the protobase, real_estate or property_portal databases
bun run typecheck tsc --noEmit
bun run check:boundaries dependency-cruiser package rules
bun run check typecheck, the unit, snapshot, integration and end-to-end tests a change affects (all of them without CHECK_BASE), and check:boundaries
bun run storybook Storybook on port 6006
bun run build-storybook static Storybook build; its toolbar switches every story between light and dark
bun run screenshots / bun run screenshots:dark screenshots of the stories tagged website, in light into screenshots/, in dark into screenshots/dark/
bun run build:serve the serve runtime, dist/protobase-serve.js (see Deploy)
bun run docs:dev this site on port 4321
bun run docs:build this site, built into docs/website/dist/; fails on broken links
bun run release --dry-run the next version and its changelog, from the commits since the last release (see Versioning)
bun run docs:check opens every page of the built site in Chromium and fails on console errors and failed requests; BASE=https://docs.protobase.net checks the live site

Each public import is a package in packages/ (@protobase/schema, layout, query, client, ui, server, config for protobase.config.ts, mobile for protobase mobile, and cli for the protobase command); packages/presets writes the projects a new app starts from and is not published; packages/try builds protobase-try.exe for Try it on Windows and is not published either; packages/create-protobase is npm create protobase, with every preset. See Architecture for the layout and import rules.