Skip to content
clientdb

Search the docs

Find a page or section

Get started

Installation

Install the clientdb packages from npm.

Requirements

  • Node 22 or newer
  • Postgres 14 or newer (CI runs 16 and 17)
  • TypeScript 5.5 or newer (the repo itself uses TypeScript 7)
  • Prisma 7, if you use the Prisma integration

Add the packages

For a Next.js app with Prisma and React:

Terminal
npm install @clientdb/schema @clientdb/client @clientdb/server @clientdb/prisma @clientdb/react
PackageWhat it's for
@clientdb/schemamodels, fields, relations and claims, shared by server and clients
@clientdb/clientthe database on the device; test helpers in @clientdb/client/testing
@clientdb/serverpermission rules, the sync engine, the route handler (@clientdb/server/next), test helpers (@clientdb/server/testing) and the clientdb command
@clientdb/prismabuilds the schema from your Prisma models; the generator, the bookkeeping models and the triggers (clientdb-prisma)
@clientdb/reactlive(), useLive() and DatabaseProvider
@clientdb/mobxinstead of, or next to, @clientdb/react: makes the data MobX-observable (mobx is a peer dependency)

Without Prisma, leave out @clientdb/prisma and write the schema in TypeScript. The packages ship compiled JavaScript with types, so there's nothing to add to next.config.ts.

The server package uses pg over TCP. Next.js route handlers run on Node.js by default, so no route segment config is needed; don't add runtime or dynamic exports (Next 16 rejects them with cacheComponents).

Licenses

The packages that run in your app's clients (schema, client, core, react, mobx) are Apache-2.0. The server engine (server, prisma) is FSL-1.1-ALv2, which becomes Apache-2.0 two years after each release. Running the engine as the backend of your own app, commercial or not, is allowed. See LICENSE.md.

Working on clientdb itself

Terminal
corepack enable                            # once; uses the Yarn version pinned in package.json
yarn install
yarn workspace @clientdb/prisma generate   # Prisma fixture client (needed by typecheck and Prisma tests)
yarn typecheck
yarn test                                  # server and Prisma tests need CLIENTDB_TEST_PG=postgres://…
yarn spec:generate                         # regenerate spec vectors (CI checks they are current)
yarn web dev                               # this website