betavoidbase is in public beta. It runs, the API is PocketBase's and is not moving, and the version is still 0.x for everything around that.Help us get it to 1.0

Connect with the SDK

voidbase answers PocketBase's API, so the client library is PocketBase's, installed from npm and pointed at your instance. Nothing about it is voidbase-specific.

Install it

bun add pocketbase        # or: npm install pocketbase

Use it

The only thing you supply is the address of your instance. Everything after that is the SDK's own API, and works exactly as its documentation says.

import PocketBase from "pocketbase";

const pb = new PocketBase("https://your-instance.example.com");

// sign in; the token is kept in pb.authStore and sent with every request after this
await pb.collection("users").authWithPassword("you@example.com", "your-password");

// read, with filtering, sorting and related records in one call
const posts = await pb.collection("posts").getList(1, 20, {
  filter: "published = true && author.verified = true",
  sort: "-created",
  expand: "author",
});

// write
await pb.collection("posts").create({ title: "Hello", body: "...", author: pb.authStore.record?.id });

// and follow changes as they happen, over one connection
pb.collection("posts").subscribe("*", (e) => console.log(e.action, e.record));

The auth token lives in pb.authStore, so signing in once covers the rest of the session, and in a browser it is persisted for you. File URLs come from pb.files.getURL(record, filename), with a thumb option for a resized version.

One SDK instance for the whole application is the intended pattern on the client side. On a server, make one per request instead, so one user's token never leaks into another user's call.

Where to read on

All of this applies to voidbase without translation:

No instance to point at yet? Run one in about a minute.

Found something wrong on this page?

Fix it yourself. The link below opens this file in GitHub's editor and forks the repository for you if you need one, and your change becomes a pull request without leaving the browser.