Getting Started

vibecode-db is a unified, type‑safe data layer for front‑end apps. Define your schema once, get Zod validation and TypeScript inference for free, and query through a single fluent API—then swap storage/backends by changing the adapter (Web/Expo SQLite or Supabase) without rewriting queries. This page gives you the big picture so you can connect the dots before diving into details.

Watch: Introduction to Vibecode DB

Get a quick visual overview of how vibecode-db works and what makes it powerful:


Why vibecode-db

Front‑end apps juggle multiple data targets (local, offline, cloud) and often duplicate models, validators, and types. vibecode-db keeps these in one place:

  • Single schema → Zod + TS types for runtime validation and compile‑time safety.
  • One query builder across environments (Web, Expo/React Native, server, or Supabase).
  • First‑class relations (1‑to‑1, 1‑to‑many) with ergonomic reads/writes.
  • Adapter swap: move from local SQLite to Supabase (or back) with minimal code change.

Key capabilities at a glance

  • Schema DSL (defineSchema, vibecodeTable, typed columns) → Zod validators and inferred types.
  • Relational modeling with referential integrity helpers.
  • Fluent query builder: select / insert / update / delete, filters, modifiers, aggregations.
  • Migrations & seeding primitives suitable for Web/Expo/Server.
  • Runs everywhere:
    • Web: SQLite in the browser via WASM (persistence via OPFS/IndexedDB).
    • Expo / React Native: SQLite on‑device.
    • Server / Node: SQLite core (file or in‑memory) for tools/tests.
    • Supabase: remote Postgres via HTTP with the same client surface.

Monorepo & packages

  • @vibecode-db/client – the unified client, schema, query builder, and types.
  • @vibecode-db/sqlite-web – browser/WASM SQLite adapter with optional persistence.
  • @vibecode-db/sqlite-expo – React Native/Expo SQLite adapter for on‑device data.

Pick the package(s) that match your runtime; the API you write stays the same.


When to use which adapter

ContextAdapterNotes
Browser app (needs offline/read-heavy)sqlite-webWASM SQLite; can persist via OPFS/IndexedDB; zero network latency.
Expo / React Native (mobile)sqlite-expoOn-device SQLite; great for offline-first and hybrid sync.
Cloud Postgres with RLS/authSupabase (via @vibecode-db/client)Same query surface; remote data + policies.

What you’ll do next

  • Install the client and the adapter for your environment.
  • Define your schema (columns + relations) and get types/validators instantly.
  • Query your data with the same API—locally or in the cloud.

That’s the whole idea: one mental model, portable everywhere. From here, continue to Core Concepts for the mental model, or jump to Adapters to wire up your environment.