npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@prisma-idb/idb-client-generator

v0.38.0

Published

Prisma generator for a type-safe IndexedDB client with optional sync

Readme

Prisma IDB

You already write Prisma on the server. Now write it in the browser.

@prisma-idb/idb-client-generator is the npm package that generates a type-safe IndexedDB client with the Prisma-style API you already know, plus an optional sync engine for offline-first apps.

Documentation · Live Demo · Repository


What this package does

This package is a Prisma generator. You add it to your Prisma schema, run prisma generate, and it produces a client in your app that talks to IndexedDB with familiar Prisma-style queries.

The difference

Even with the idb library, querying across relations means manual index lookups, joins in application code, and no generated types:

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);

Prisma IDB:

const posts = await idb.post.findMany({
  where: { authorId: userId, published: true },
  include: {
    comments: { orderBy: { createdAt: "desc" } },
  },
  orderBy: { createdAt: "desc" },
});

Same API shape as Prisma Client. Fully typed. Local-first.

And when you need sync

Most IndexedDB libraries stop at CRUD. Prisma IDB can also generate a bidirectional sync layer that handles the harder parts:

generator prismaIDB {
  provider   = "idb-client-generator"
  output     = "./prisma-idb"
  outboxSync = true
  rootModel  = "User"
}
  • Outbox pattern for reliable local mutations and retries
  • Ownership DAG so sync authorization is structural
  • Conflict handling through server-authoritative changelog materialization

Quick Start

Install

pnpm add idb
pnpm add -D @prisma-idb/idb-client-generator

You will also need your normal Prisma setup, including prisma and @prisma/client.

Configure

Add the generator to your schema.prisma:

generator prismaIDB {
  provider = "idb-client-generator"
  output   = "./prisma-idb"
}

model Todo {
  id    String  @id @default(cuid())
  title String
  done  Boolean @default(false)
}

If you enable sync, use a single client-generated ID field such as cuid() or uuid() on syncable models.

Generate

pnpm exec prisma generate

Use the generated client

import { PrismaIDBClient } from "./prisma-idb";

const idb = await PrismaIDBClient.createClient();

await idb.todo.create({
  data: { title: "Ship it", done: false },
});

const todos = await idb.todo.findMany({
  where: { done: false },
});

await idb.todo.update({
  where: { id: todoId },
  data: { done: true },
});

Features

  • Prisma-compatible API for IndexedDB CRUD and queries
  • Full type safety generated from your Prisma schema
  • include and select support for relations
  • Offline-first operation with no network dependency for local reads and writes
  • Optional sync for bidirectional server reconciliation
  • Client-generated IDs for local creates without round-trips

Resources

Contributing

Contributions welcome. See CONTRIBUTING.md.

Security

See SECURITY.md for reporting vulnerabilities.

License

MIT. See LICENSE.

Disclaimer

Prisma is a trademark of Prisma. Prisma IDB is an independent open-source project, not affiliated with or endorsed by Prisma.