# Repository: pubkey/rxdb # Stars: 23147 ## CLAUDE.md # CLAUDE.md ## Build Commands - **Build All**: `npm run build` - **Documentation Build**: `npm run docs:build` ## Test Commands - **Run All Tests**: `npm run test` - **Fast Tests (Parallel)**: `npm run test:fast` - **Fast Memory Tests**: `npm run test:fast:memory` - **Node Tests**: `npm run test:node` - **Browser Tests**: `npm run test:browser` - **Performance Tests**: `npm run test:performance` - **Lint**: `npm run lint` - **Lint Fix**: `npm run lint:fix` - **Check Types**: `npm run check-types` ## Development Scripts - **Unwatch Tests**: `npm run dev` - **Watch Example**: `npm run dev:example` - **Generate Error Messages**: `npm run generate:error-messages` - **Start Docs Server**: `npm run docs:serve` ## Code Style & Patterns - **Language**: TypeScript - **Database**: RxDB (local-first, NoSQL) - **State Management**: Reactive (RxJS Observables) - **Formatting**: Uses ESLint. Run `npm run lint` to check and `npm run lint:fix` to auto-fix. - **Imports**: Uses ES modules (import/export). - **Paths**: Source code in `src/`, tests in `test/`, documentation in `docs-src/`. - **TypeScript**: Do not use enums. Prefer types instead of interfaces. - **Errors**: Do not use `throw new Error()`. Use `throw newRxError()` or `throw newRxTypeError()` instead to reduce build size and do not include full error messages in production builds. Use the error codes from `src/rx-error.ts` and add new error codes if needed like `PL1`, `PL2`. Example: `throw newRxError('PL1', { plugin });` ## Development Workflow ```sh # 1. Make changes # 2. Build npm run build # 3. Run tests npm run test:fast:memory # 4. Run lint npm run lint # 5. Check TypeScript types npm run check-types ``` ## Documentation Style - SHOULD use clear, simple language. - SHOULD use data and examples to support claims when possible. - SHOULD be informative. - SHOULD focus on practical, actionable insights. - AVOID using em dashes (–) anywhere. - AVOID constructions like "not just this, but also this". - AVOID metaphors and cliches. - AVOID generalizations. - AVOID upfront warnings or notes, just the output requested. - AVOID rhetorical questions. - AVOID specific words like: very, really, literally, actually, certainly, probably, basically, delve, embark, enlightening, esteemed, shed light, craft, creative, imagine, realm, game-changer, unlock, discover, skyrocket, abyss, not alone, in a world where, revolutionize, disruptive, utilize, utilizing, dive deep, tapestry, illuminate, unveil, pivotal, intricate, elucidate, hence, furthermore, realm, however, harness, exciting, groundbreaking, cutting-edge, remarkable, it remains to be seen, glimpse into, navigating, landscape, stark, testament, in summary, in conclusion, moreover, boost, skyrocket, opened up, powerful, inquiries, ever-evolving. - Review your response and ensure no em dashes. - MUST format FAQ sections using HTML `
` and `` tags. Ensure there is an empty line before and after the inner markdown content so it parses correctly. - SHOULD try to use components from the `docs-src/src/components` folder when writing docs. ## README.md

JavaScript Database

A fast, local-first, reactive Database for JavaScript Applications


       

     


  What is RxDB?

RxDB (short for Reactive Database) is a local-first, NoSQL-database for JavaScript Applications. Reactive means that you can not only query the current state, but subscribe to all state changes like the result of a query or even a single field of a document. This is great for UI-based realtime applications in a way that makes it easy to develop and also has great performance benefits.

Use the [quickstart](https://rxdb.info/quickstart.html), read the [documentation](https://rxdb.info/install.html) or explore the [example projects](https://github.com/pubkey/rxdb/tree/master/examples).

  Used by many

RxDB is a proven technology used by [thousands of developers](https://github.com/pubkey/rxdb/network/dependents) worldwide. With its flexibility, RxDB is used in a diverse range of apps and services.
(add yours)

  Multiplayer realtime applications

![realtime.gif](docs-src/static/files/animations/realtime.gif)

  Replicate with your existing infrastructure

RxDB provides an easy to implement, battle-tested Sync Engine for realtime replication with your existing infrastructure.
You do not have to use a specific cloud or backend database. The protocol works by implementing three simple HTTP endpoints. There are also production-ready plugins to easily replicate with GraphQL, CouchDB, Websocket, WebRTC (P2P), Supabase, Firestore, NATS or Google Drive.

  Flexible storage layer

RxDB is based on a [storage interface](https://rxdb.info/rx-storage.html) that enables you to swap out the underlying storage engine. This increases **code reuse** because the same database code can be used in different JavaScript environments by just switching out the storage settings. You can use RxDB on top of [LocalStorage](https://rxdb.info/rx-storage-localstorage.html), [IndexedDB](https://rxdb.info/rx-storage-indexeddb.html), [OPFS](https://rxdb.info/rx-storage-opfs.html), [LokiJS](https://rxdb.info/rx-storage-lokijs.html), [Dexie.js](https://rxdb.info/rx-storage-dexie.html), [in-memory](https://rxdb.info/rx-storage-memory.html), [SQLite](https://rxdb.info/rx-storage-sqlite.html), in a [WebWorker](https://rxdb.info/rx-storage-worker.html) thread and even on top of [FoundationDB](https://rxdb.info/rx-storage-foundationdb.html) and [DenoKV](https://rxdb.info/rx-storage-denokv.html). No matter what kind of runtime you have, as long as it runs JavaScript, it can run RxDB:

Browsers Node.js React Native Capacitor NativeScript Flutter or as an Electron Database

All the features that you need

Since its beginning in 2018, RxDB has gained a huge set of features and plugins which makes it a flexible full solution regardless of which type of application you are building. Every feature that you need now or might need in the future is already there.
Logging
Attachments
ORM
Conflict Handling
Middleware
Signals
State
Backup
Replication
Server
Storages
Local Documents
Schema Validation
Compression
Migration
Encryption
CRDT
Population

  Quick start

#### Install ```sh npm install rxdb rxjs --save ``` #### Store data ```javascript import { createRxDatabase } from 'rxdb/plugins/core'; /** * For browsers, we use the localstorage based storage. * In other JavaScript runtimes, we can use different storages: * @link https://rxdb.info/rx-storage.html */ import { getRxStorageLocalstorage } from 'rxdb/plugins/storage-localstorage'; // create a database const db = await createRxDatabase({ name: 'heroesdb', // the name of the database storage: getRxStorageLocalstorage() }); // add collections with a schema await db.addCollections({ heroes: { schema: { version: 0, primaryKey: 'name', type: 'object', properties: { name: { type: 'string', maxLength: 100 }, healthpoints: { type: 'number' } }, required: ['name', 'healthpoints'] } } }); // insert a document await db.heroes.insert({ name: 'Bob', healthpoints: 100 }); ``` #### Query data once ```javascript const aliveHeroes = await db.heroes.find({ selector: { healthpoints: { $gt: 0 } } }).exec(); // the exec() returns the result once ``` #### Observe a Query ```javascript await db.heroes.find({ selector: { healthpoints: { $gt: 0 } } }) .$ // the $ returns an observable that emits each time the result set of the query changes .subscribe(aliveHeroes => console.dir(aliveHeroes)); ```

  Get started

Get started now by [reading the docs](https://rxdb.info/quickstart.html) or exploring the [example-projects](./examples).

  Support and Contribute

- **Leave a Star ☝️** - [Check out how you can contribute to this project](https://rxdb.info/contribution.html). - [Read this when you have found a bug](./orga/bug-checklist.md) - [Buy access to the premium plugins](https://rxdb.info/premium/) - [Join us at discord to get help](https://rxdb.info/chat) - [Follow us at LinkedIn](https://www.linkedin.com/company/rxdb/) #### More content [Angular Database](https://rxdb.info/articles/angular-database.html), [Frontend Database](https://rxdb.info/articles/frontend-database.html), [localStorage](https://rxdb.info/articles/localstorage.html), [React Database](https://rxdb.info/articles/react-database.html), [Browser Database](https://rxdb.info/articles/browser-database.html), [React Native Database](https://rxdb.info/react-native-database.html), [PWA Database](https://rxdb.info/articles/progressive-web-app-database.html), [In-memory NoSQL database](https://rxdb.info/articles/in-memory-nosql-database.html), [JSON database](https://rxdb.info/articles/json-database.html), [Angular IndexedDB](https://rxdb.info/articles/angular-indexeddb.html), [React IndexedDB](https://rxdb.info/articles/react-indexeddb.html), [Optimistic UI](https://rxdb.info/articles/optimistic-ui.html), [local database](https://rxdb.info/articles/local-database.html), [React Native Encryption](https://rxdb.info/articles/react-native-encryption.html), [Vue Database](https://rxdb.info/articles/vue-database.html), [jQuery Database](https://rxdb.info/articles/jquery-database.html), [Vue IndexedDB](https://rxdb.info/articles/vue-indexeddb.html), [Firestore Alternative](https://rxdb.info/articles/firestore-alternative.html), [Firebase Realtime Database Alternative](https://rxdb.info/articles/firebase-realtime-database-alternative.html), [Ionic Storage](https://rxdb.info/articles/ionic-storage.html) ---------------- View [llms.txt](https://rxdb.info/llms.txt)