vibes.diy ← Creator Documentation
use-vibes@2.2.18

Your Vibes app's database,
from any JS backend

Your app's live data is accessible outside the browser — from Node, Deno, Bun, Cloudflare Workers, or any runtime that can run npm packages.

before you start

Prerequisites

Login once per device — stores a device cert in your keybag.

npx vibes-diy login$ npx vibes-diy login

Install the package. Works with npm, pnpm, and yarn.

npm install use-vibes$ npm install use-vibes

// Deno / Bun: import { fireproof } from "https://esm.sh/use-vibes@2.2.18"

start here

Minimal working example

Connect to the same database that backs your Vibes app. You need two things from your vibe's URL (vibes.diy/vibe/userSlug/appSlug): the appSlug, and the database name your App.jsx passes to fireproof().

import { fireproof } from "use-vibes"; // appSlug is the last segment of your vibe's URL: vibes.diy/vibe// const db = fireproof("todos", { appSlug: "my-todo-app" }); const ok = await db.put({ text: "hello from Node" }); const doc = await db.get(ok.id); const { docs } = await db.query("type", { key: "todo" }); db.subscribe((changes) => { console.log("live update:", changes); }, true);import { fireproof } from "use-vibes";

// appSlug is the last segment of your vibe's URL: vibes.diy/vibe/<userSlug>/<appSlug>
const db = fireproof("todos", { appSlug: "my-todo-app" });

const ok = await db.put({ text: "hello from Node" });
const doc = await db.get(ok.id);
const { docs } = await db.query("type", { key: "todo" });

db.subscribe((changes) => {
  console.log("live update:", changes);
}, true);
configuration

How defaults resolve

When you call fireproof("todos") with no options, these defaults apply in order.

FieldDefault
apiUrl VIBES_DIY_API_URL env var, then https://vibes.diy/api
appSlug VIBES_APP_SLUG env var, then basename(process.cwd()) — pass explicitly to avoid connecting to the wrong vibe
getToken device cert from npx vibes-diy login keybag
userSlug looked up automatically from your account on first request

Explicit config

For CI, Wrangler, or service accounts — environments without a device keybag.

const db = fireproof("todos", { apiUrl: "https://vibes.diy/api", appSlug: "my-app", userSlug: "alice", getToken: async () => myTokenResult, });const db = fireproof("todos", {
  apiUrl: "https://vibes.diy/api",
  appSlug: "my-app",
  userSlug: "alice",
  getToken: async () => myTokenResult,
});
important

Instance caching

These rules apply per process — important for long-running scripts and Workers.

v1 limitations

What's not supported yet

reference

Available methods

These are the only methods. Do not use others.

MethodNotes
put(doc) Write a document. Returns { id, clock }. verified
get(id) Fetch a document by id. verified
del(id) Delete a document by id. verified
query(field, opts) Index query by field value. verified
subscribe(fn, runNow?) Live updates over WebSocket. Second arg fires immediately. verified
allDocs(opts?) Fetch all documents. listed, unverified
bulk(docs) Batch write. listed, unverified

Ready to connect?

Open your Vibes app, grab the appSlug from its URL and the database name from your App.jsx, and start reading data from your script.