Get started
What is clientdb?
A data layer that makes your app feel instant, and lets you delete most of your API code.
clientdb keeps each user's data in their browser, and keeps it in sync with your Postgres.
That one idea changes how you build an app:
- Your UI reads data like local variables. The data is already on the device, so there's nothing to fetch and no spinner per component. Lists, filters and counts are instant, even with 100,000 items. You choose which data loads up front; the rest arrives the first time something reads it.
- Your UI writes data like local variables. A change shows on screen immediately and is saved in the background. Undo comes for free.
- Your backend shrinks to one file. Instead of an API route for every read and write, you describe who may see and change what, once. clientdb enforces it on the server for every request.
- Everyone stays up to date. When someone changes something, everyone else who can see it gets the change, in every open tab and device. When someone loses access, the data disappears from their devices too.
import { live, useLive } from "@clientdb/react";
import { db, type Todo } from "@/sync/db";
function Todos({ projectId }: { projectId: string }) {
const todos = useLive(() => {
return db.todo.where({ projectId }).orderBy("createdAt", "desc").all;
});
return todos.map((todo) => {
return <TodoRow key={todo.id} todo={todo} />;
});
}
const TodoRow = live(({ todo }: { todo: Todo }) => {
return (
<input
value={todo.title}
onChange={(event) => {
todo.update({ title: event.target.value });
}}
/>
);
});No fetch, no API route, no cache keys. The rename is checked against your permissions on the server, and every teammate looking at the list sees it.
It works with what you have
- Postgres, any provider (Neon, Supabase, RDS, local). Your data stays in your tables.
- Prisma: your
schema.prismastays the source of truth. clientdb reads your models from it. - Next.js: one route handler serves everything. It runs on serverless hosts like Vercel with no background process.
- React (with or without MobX), and a native Swift client for iPhone and Mac.
There's no hosted service and nothing to sign up for. clientdb is a library that runs in your app.
When it's a good fit
clientdb shines in apps where people work with their own or their team's data and expect it to feel fast: project tools, CRMs, dashboards, editors, internal tools. The approach is inspired by apps like Linear, which feel instant because the data is already on your device.
It's less of a fit for public, content-heavy sites (a blog, a store catalogue) where every visitor sees the same pages and there's nothing personal to keep locally.
Where to go next
Using an AI assistant?
The docs are available as plain text for LLMs: /llms.txt (an index) and /llms-full.txt (every page). Each page also has a "Copy page as Markdown" button.
Install
The packages are on npm: npm install @clientdb/client @clientdb/server, and the rest are listed in Installation. The client packages are Apache-2.0; the server engine is FSL-1.1-ALv2, which allows running it as the backend of your own app.