RxDB (Reactive Database) is a local-first, NoSQL database designed for JavaScript applications, including websites, hybrid apps, Electron, Progressive Web Apps, and Node.js. Currently stable at version 17.1.0, it follows a release cadence with frequent beta cycles leading to major versions and subsequent point releases for bug fixes. Its core differentiator is its reactive architecture, leveraging RxJS to provide observable queries and real-time data changes. RxDB supports offline-first operation, enforces data integrity through JSONSchema-based validation, and offers a highly pluggable synchronization engine for diverse backends like HTTP, GraphQL, WebRTC (P2P), CouchDB, MongoDB, Supabase, and even serverless options such as Google Drive and Microsoft OneDrive. Key features include conflict resolution (e.g., CRDTs), encryption, and robust data migration capabilities for evolving schemas and underlying storage adapters, ensuring data consistency across multiple client instances and browser tabs.
npm install rxdbVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create an RxDB database, define a schema, add a collection, insert and query documents, and subscribe to real-time changes using the Dexie storage adapter. It also shows the conditional inclusion of the DevMode plugin for development.
Consult the RxDB v17 migration guide (rxdb.info/releases/17.0.0.html) and use the Storage Migration Plugin to safely transfer your existing data to the new format or storage. The Storage Migration Plugin is now part of open-core since v15.
Migrate your existing PouchDB-based RxDB applications to another RxStorage, such as `getRxStorageDexie` or `getRxStorageIndexeddb` (for browser environments), or `getRxStorageMongoDB` (for Node.js). The Storage Migration Plugin can assist with this transition.
Update your JSON schemas to include a `primaryKey` property at the top level, specifying the field that serves as the unique identifier for documents in the collection.
Conditionally add `RxDBDevModePlugin` only in development environments (e.g., `if (process.env.NODE_ENV !== 'production') { addRxPlugin(RxDBDevModePlugin); }`).Ensure all `addRxPlugin()` calls for necessary plugins (e.g., storage adapters, dev mode, replication) are executed synchronously before initializing your RxDatabase instance.
If you need to modify data retrieved from RxDB, create your own deep clone of the document objects before making any changes.
For WebViews and native desktop/mobile applications, prefer robust storage solutions like SQLite-based RxStorages (often premium features) over IndexedDB to ensure data persistence and integrity.
In development, enable the `RxDBDevModePlugin` (`addRxPlugin(RxDBDevModePlugin)`) to receive full, human-readable error messages including cause, fix suggestions, and documentation links. For production errors, refer to the RxDB documentation using the error code.
Ensure your environment supports `crypto.subtle.digest` (Node.js >=18, browser on HTTPS/localhost). Alternatively, provide a custom `hashFunction` option when creating the database if `crypto.subtle` is unavailable or problematic.
Review your application's initialization code to ensure each RxDB plugin is added only once. Check your dependency tree for duplicate package installations if this persists.
Always increment the `version` property in your schema definition when making structural changes. If existing data needs to be transformed, define `migrationStrategies` when adding the collection to handle data updates from previous schema versions.
Ensure that any document you insert or upsert explicitly includes the field defined as the `primaryKey` in your RxCollection's schema. This field is mandatory for document identification.