Skip to content

Quick start

From a fresh checkout to your first record over the REST API, in under five minutes.

  • 8 steps
  • ~5 min
  • Requires Bun
  • Updated for v0.27.1
Terminal
git clone https://github.com/vaultbase-sh/vaultbase
cd vaultbase
bun install
(cd admin && bun install) # the admin UI has its own dependencies
bun run build # compiles admin + binary → ./vaultbase
./vaultbase # starts on :8091

The first bun run build takes about 30 seconds (it compiles the admin UI and bundles the Bun binary). After that, ./vaultbase starts in milliseconds.

The command above runs on SQLite: a data.db file in ./vaultbase_data, nothing to set up. For this guide that is all you need.

To run on Postgres (beta) instead, stop it and start it with the URL of an empty database:

Terminal
VAULTBASE_DATABASE_URL=postgres://user:pass@localhost:5432/vaultbase ./vaultbase

Choose before you create the admin: the server uses one database, and nothing is copied between them. See Databases for how they differ.

Open localhost:8091/_/. On a fresh install you’ll see a setup wizard; its first step shows which database the server is on.

  1. Pick an admin email and password (12+ characters by default).
  2. Sign in with them. You land on the Dashboard.

Open Collections, click New collection and fill in the modal:

Name
posts
Type
Base (default)
Schema
+text title, Required · +text body

Click Create collection. Behind the scenes Vaultbase creates a real table with native columns, not a JSON blob:

SQL · generated
CREATE TABLE vb_posts (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
body TEXT,
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
updated_at INTEGER NOT NULL DEFAULT (unixepoch())
);

New collections are admin-only: until you open them up, GET /api/v1/posts returns 403 to anyone who isn’t an admin. Open the posts collection, switch to the API rules tab and set:

List
Public
View
Public
Create
Auth only — any signed-in user
Update / Delete
Admin only (leave as is)

Click Save. Anyone can now read posts; creating one needs a signed-in user. Read more about rules →

Open the posts collection, click New record, fill in title and body, then Create. It appears in the table.

Terminal window
# List records
curl http://localhost:8091/api/v1/posts
Response · 200 OK
{
"data": [{
"id": "abc-123",
"collectionName": "posts",
"title": "hello",
"body": "world",
"created": 1730000000,
"updated": 1730000000
}],
"page": 1, "perPage": 30, "totalItems": 1, "totalPages": 1
}

Save this as watch.ts and run bun watch.ts:

watch.ts
const ws = new WebSocket("ws://localhost:8091/realtime");
ws.onopen = () => ws.send(JSON.stringify({ type: "subscribe", topics: ["posts"] }));
ws.onmessage = (e) => console.log(JSON.parse(e.data));

Create or edit a post in the admin and the event prints live.

To see it all in an app, the todo example has sign-in, rules that keep each user’s todos private, and realtime sync across tabs, in one TypeScript file.