Prisma 8 IDB
A typed IndexedDB client for Prisma 8, with migrations and optional sync
Prisma 8 IDB stores your app's data in the browser's IndexedDB, using a Prisma schema you already know how to write. It's in preview.
You describe your models in a .prisma file. The prisma CLI turns the schema into a typed contract. A second CLI, prisma-idb, plans migrations and bundles them into your app. In the browser, the client applies any pending migrations when it opens the database, then gives you typed queries:
const db = await getDb();
await db.orm.todo.create({ id: crypto.randomUUID(), title: "Write docs", done: false, userId });
const open = await db.orm.todo.where({ done: false }).orderBy({ title: "asc" }).all();What you get
- Your schema, in the browser. Models, relations,
@id,@unique,@@indexand@defaultmap onto IndexedDB object stores and indexes. - Typed, chainable queries.
where,orderBy,include,aggregateand friends. The API is chained calls, not Prisma Client's single argument object. - Relations enforced like a SQL database. Foreign keys are checked on every write, and
onDeleteandonUpdateactions run in the same transaction. - Reviewed migrations. Schema changes are planned on your machine, committed, and applied in each user's browser the next time the app opens.
- Optional sync. Two packages keep IndexedDB and a server database in step, per user.
How it fits together
| Step | Where it runs | What happens |
|---|---|---|
Write schema.prisma | Your editor | You describe your models. |
| Emit the contract | CLI | prisma contract emit writes contract.json and its types. |
| Plan a migration | CLI | prisma-idb migration plan writes a migration package you commit. |
| Bundle migrations | CLI | prisma-idb migration contract-space writes a module your app imports. |
| Open the database | Browser | The client applies pending migrations, then you query. |