Skip to content
clientdb

Search the docs

Find a page or section

Reference

FAQ and limits

Common questions, and what clientdb deliberately doesn't do (yet).

Do I need WebSockets?

No. The Next.js handler syncs over plain HTTP: on load, on focus, after writes and on an interval. Add the WebSocket server when you want instant push; both share the same log.

Does it work on Vercel and Neon?

Yes. Route handlers run on Node.js by default (no runtime export needed); use a small pool; the request path works through Neon's pooled URL. Run engine.migrate() over a direct connection. There are no replication slots, so Neon branch restores and scale-to-zero are fine. See Postgres and Neon.

Do I have to move my data?

No. With Prisma, rows stay in Prisma's tables; the engine keeps its metadata in a side table and runs no DDL. engine.migrate() adopts existing rows (about 2 s per 20,000), and on every later run adopts rows written outside clientdb since.

What if my server code writes with Prisma directly?

That works without any clientdb calls in your write code. Install the triggers migration once (npx clientdb-prisma triggers), and Postgres records the ids of every changed row: Prisma writes (nested and *Many included), raw SQL, other services and ON DELETE CASCADE. The engine syncs them on the next pull or push, or immediately when engine.start() runs. Regenerate the migration when you add a synced model.

As a safety net, await engine.reconcile() compares your tables with clientdb's last synced copies and syncs the differences; it also runs inside engine.migrate(), and you can run it from a cron. If you'd rather not use triggers, pass the changed ids yourself with await engine.changed({ project: [project.id] }), inside the write's transaction to make it atomic. See Untracked rows.

Where does server-side business logic go?

In your own server actions, tRPC procedures or API routes, writing with Prisma as usual. On the device, wrap the call in db.$action(…): it resolves once what the action wrote has synced to this device. See Server logic with $action.

How is this different from caching API responses?

There are no per-endpoint queries to keep fresh. Each client holds a replica of exactly the rows it may read, and the server pushes precise deltas, including when access changes. Reads never wait on the network.

Can a client see data it shouldn't, even briefly?

The engine never sends a row to a user whose groups don't include it, and a restricted field only to users its field rule allows. Rows that leave a device go as id-only deletes. Property tests check this against a reference implementation of the rules after every simulated step.

What happens when two people edit the same field?

The last write committed on the server wins, per field, on every client. Edits to different fields of the same row never conflict. See Conflicts.

What about old app versions?

They reload. A schema hash mismatch puts the client in outdated state. There are no compatibility windows by design.

My component doesn't update when data changes

useLive tracks only what its function reads. Fields and relations you read from its result while rendering aren't tracked; wrap that component in live(). In development, clientdb logs a warning naming the read. See Reactivity.

My read rule fails with AccessCompileError

Every read branch needs a viewer condition. For data every signed-in user may read, write $.and($.authenticated, …); for anonymous access, $.public. See Permissions.

Can I use it without React?

Yes. Reads and writes are plain synchronous calls, and computed and effect from @clientdb/client work anywhere (from @clientdb/mobx with a MobX client). With MobX, every surface is observable. See Outside React.

Limits

  • Writes made outside clientdb need the triggers migration. Without it, they sync only after engine.reconcile() or engine.changed() (the handlers warn about them in development).
  • One tenant on Prisma tables. Tenancy inside the app comes from your rules. Row-level security applies to engine-owned tables only.
  • fromPrisma rejects ids that aren't String, composite foreign keys, @map on enum values, Bytes and other unsupported types, and @default functions it doesn't know, with an error that names the field.
  • BigInt values beyond 2^53 lose precision on clients.
  • Not built yet: scale-out infrastructure (cells, tenant directory, posting-list delta index); a TC39 Signals adapter.
  • Collaborative text editing is out of scope; the design leaves room for it.