Prisma generator for IndexedDB
You already write Prisma on the server. Now write it in the browser.
A Prisma generator that creates a type-safe IndexedDB client with the API you already know — plus an optional sync engine that handles conflict resolution, ownership, and offline-first data for you.
The same API. Zero learning curve.
Even with the idb library, querying across relations means manual index lookups, joins in application code, and zero type safety:
const db = await openDB("MyDB", 1);
const posts = await db.getAllFromIndex(
"posts", "byAuthor", userId
);
const result = [];
for (const post of posts) {
if (!post.published) continue;
const comments = await db.getAllFromIndex(
"comments", "byPost", post.id
);
result.push({ ...post, comments });
}
result.sort(
(a, b) => b.createdAt - a.createdAt
);
// manual joins, no types, no filteringconst posts = await idb.post.findMany({
where: {
authorId: userId,
published: true,
},
include: {
comments: {
orderBy: { createdAt: "desc" },
},
},
orderBy: { createdAt: "desc" },
});
// Typed. Relations included.
// Filtering, sorting, nesting —
// all generated from your schema.See it in action
A full-stack Kanban board with bidirectional sync. Go offline, make changes, come back — everything syncs across devices.
The demo uses manual sync controls. In production, call worker.start() for fully automatic background sync.
Sync that's built in,
not bolted on.
Most IndexedDB wrappers stop at CRUD. Prisma IDB generates a full sync engine from your schema — wire up two endpoints and a sync worker, and it handles the rest.
Works Offline, Syncs Later
Mutations queue locally and push automatically with retry and batching when the network is back.
Built-in Authorization
Every record knows who owns it — authorization is built into your schema, not bolted on with middleware.
Conflict Resolution
When two devices edit the same record, the server decides. Pull operations are fast and predictable.
generator prismaIDB {
provider = "idb-client-generator"
output = "./prisma-idb"
outboxSync = true
rootModel = "User"
}Three steps to full sync. Full setup guide →
How does it compare?
There are great tools for client-side storage. Prisma IDB is built for teams already using Prisma who want the same API in the browser — with sync included.
| Feature | Prisma IDB | Dexie.js | RxDB | ElectricSQL |
|---|---|---|---|---|
| Prisma-compatible API | ||||
| Type-safe from schema | ||||
| Relations & nested queries | ||||
| Bidirectional sync | ||||
| Conflict resolution | ||||
| Offline-first | ||||
| No vendor lock-in | ||||
| Zero runtime config |
Supported Partial Not included
Built for speed. Measured honestly.
Benchmarks run entirely in the browser — no server, no network. The numbers below come straight from the latest CI snapshot on main.
Loading latest benchmark snapshot…
Fetching the most recent CI run from the public benchmark feed.
Results vary by browser, device, and dataset. Run your own to see what to expect in your environment.
Up and running in three steps
Add the generator to an existing Prisma project — no config files, no runtime dependencies.
Install
pnpm add idb @prisma-idb/idb-client-generator -DAdd the generator to your schema.prisma
generator prismaIDB {
provider = "idb-client-generator"
output = "./prisma-idb"
}Generate
npx prisma generate