Skip to content
πŸ’» πŸ”„ πŸ“± A realtime Database for JavaScript Applications
TypeScript JavaScript Other
Branch: master
Clone or download

Latest commit


Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create FUNDING.yml Oct 31, 2019
config ADD test for graphql first push bug Oct 21, 2019
dist 8.8.0 Mar 5, 2020
docs-src Revert "Add collection methods to document type" Mar 25, 2020
docs 8.8.0 Mar 5, 2020
examples Update dependency ts-node to v8.8.2 Apr 5, 2020
orga Update Mar 17, 2020
plugins FIX typings so that angular works Sep 27, 2019
scripts CHORE typescript Sep 18, 2019
src Revert "Add collection methods to document type" Mar 25, 2020
test Update dependency ts-node to v8.8.2 Apr 5, 2020
.editorconfig Add editorconfig Oct 16, 2017
.eslintignore FIX lint Sep 9, 2018
.eslintrc.json ADD graphql-sync basic sync is working now Jul 8, 2019
.gitignore BUILD Aug 5, 2019
.npmignore fix: remove scripts dir from npmignore; will fix #1509 after npm publish Sep 25, 2019
.npmrc DISABLE package-lock.json Mar 19, 2018
.travis.yml Update .travis.yml Feb 16, 2020 FIX changelog Mar 25, 2020 Update Oct 22, 2018
LICENSE.txt ADD LICENSE Dec 2, 2016 ADD hint for #669 Jun 2, 2018 Changed wording for clarity in Nov 4, 2019
babel.config.js CHORE typescript Sep 18, 2019
package.json Update dependency ts-node to v8.8.2 Apr 5, 2020 REFACTOR(query-change-detection) do not itterate over whole array to … Nov 25, 2019
renovate.json CHANGE reenable automerge Mar 3, 2020
tsconfig.json FIX typings so that angular works Sep 27, 2019
tslint.json ADD(tslint) no-async-without-await Mar 5, 2020


A realtime Database for JavaScript Applications

RxDB (short for Reactive Database) is a NoSQL-database for JavaScript Applications like Websites, hybrid Apps, Electron-Apps and NodeJs. Reactive means that you can query the current state and subscribe to all state-changes, such as the result of a query or even a single field of a document. This is useful for UI-based apps that always display the realtime state to the user. RxDB can do a realtime replication with any CouchDB compliant endpoint and also with GraphQL endpoints.

follow on Twitter


πŸ’»πŸ“± Multiplatform support for browsers, nodejs, electron, cordova, react-native and every other javascript-runtime
πŸ“¨ Reactive data-handling based on RxJS
🚣 Offline first let your app still work when the users has no internet
πŸ”„ Replication between client and server-data, compatible with pouchdbPouchDB, couchdbCouchDB and cloudantIBM Cloudant. There is also a plugin for a GraphQL replication
πŸ“„ Schema-based with the easy-to-learn standard of json-schema
🍊 Mango-Query exactly like you know from mongoDB and mongoose
πŸ” Encryption of single data-fields to protect your users data
πŸ“€πŸ“₯ Import/Export of the database-state (json), awesome for coding with TDD
πŸ“‘ Multi-Window to synchronise data between different browser-windows or nodejs-processes
πŸ’… ORM-capabilities to easily handle data-code-relations and customize functions of documents and collections
πŸ”· Full TypeScript support for fast and secure coding


RxDB is made so that you can use exactly the same code at

We optimized, double-checked and made boilerplates so you can directly start to use RxDB with frameworks like



npm install rxdb --save

# peerDependencies
npm install rxjs --save


import RxDB from 'rxdb';
const db = await RxDB.create({
    name: 'heroesdb',
    adapter: 'websql',
    password: 'myLongAndStupidPassword', // optional
    multiInstance: true                  // default: true
  });                                                       // create database

await db.collection({name: 'heroes', schema: mySchema});    // create collection
db.heroes.insert({ name: 'Bob' });                          // insert document
var RxDB = require('rxdb');
    name: 'heroesdb',
    adapter: 'websql',
    password: 'myLongAndStupidPassword', // optional
    multiInstance: true                  // default: true
  })                                                                              // create database
  .then(function(db) {return db.collection({name: 'heroes', schema: mySchema});}) // create collection
  .then(function(collection) {collection.insert({name: 'Bob'});})                 // insert document

Feature-Showroom (click to toggle)


To find data in your collection, use the mquery api to create chained mango-queries, which you maybe know from mongoDB or mongoose.

  .exec().then( docs => {

RxDB implements rxjs to make your data reactive. This makes it easy to always show the real-time database-state in the dom without manually re-submitting your queries.

  .$ // <- returns observable of query
  .subscribe( docs => {
    myDomElement.innerHTML = docs
      .map(doc => '<li>' + + '</li>')



When two instances of RxDB use the same storage-engine, their state and action-stream will be broadcasted. This means with two browser-windows the change of window #1 will automatically affect window #2. This works completely offline.



Because RxDB relies on glorious PouchDB, it is easy to replicate the data between devices and servers. And yes, the changeEvents are also synced.



Schemas are defined via jsonschema and are used to describe your data.

const mySchema = {
    title: "hero schema",
    version: 0,                 // <- incremental version-number
    description: "describes a simple hero",
    type: "object",
    properties: {
        name: {
            type: "string",
            primary: true       // <- this means: unique, required, string and will be used as '_id'
        secret: {
            type: "string",
            encrypted: true     // <- this means that the value of this field is stored encrypted
        skills: {
            type: "array",
            maxItems: 5,
            uniqueItems: true,
            item: {
                type: "object",
                properties: {
                    name: {
                        type: "string"
                    damage: {
                        type: "number"
    required: ["color"]

By setting a schema-field to encrypted: true, the value of this field will be stored in encryption-mode and can't be read without the password. Of course you can also encrypt nested objects. Example:

"secret": {
  "type": "string",
  "encrypted": true

The underlying pouchdb can use different adapters as storage engine. So you can use RxDB in different environments by just switching the adapter. For example you can use websql in the browser, localstorage in mobile-browsers and a leveldown-adapter in nodejs.

// this requires the indexeddb-adapter
// this creates a database with the indexeddb-adapter
const database = await RxDB.create({
    name: 'mydatabase',
    adapter: 'idb' // the name of your adapter

There is a big ecosystem of adapters you can use.

Import / Export

RxDB lets you import and export the whole database or single collections into json-objects. This is helpful to trace bugs in your application or to move to a given state in your tests.

// export a single collection
const jsonCol = await myCollection.dump();

// export the whole database
const jsonDB = await myDatabase.dump();

// import the dump to the collection
await emptyCollection.importDump(json);

// import the dump to the database
await emptyDatabase.importDump(json);

Imagine your website needs to get a piece of data from the server once every minute. To accomplish this task you create a websocket or pull-interval. If your user now opens the site in 5 tabs parallel, it will run the interval or create the socket 5 times. This is a waste of resources which can be solved by RxDB's LeaderElection.

  .then(() => {
      // this will only run when the instance becomes leader.
      mySocket = createWebSocket();

In this example the leader is marked with the crown β™›



Depending on which adapter and in which environment you use RxDB, client-side storage is limited in some way or the other. To save disc-space, RxDB has an internal schema-based key-compression to minimize the size of saved documents.


// when you save an object with big keys
await myCollection.insert({
  firstName: 'foo'
  lastName:  'bar'
  stupidLongKey: 5

// RxDB will internally transform it to
  '|a': 'foo'
  '|b':  'bar'
  '|c': 5

// so instead of 46 chars, the compressed-version has only 28
// the compression works internally, so you can of course still access values via the original key.names
// 'foo'

Similar to Meteors oplog-observe-driver, RxDB has a QueryChangeDetection to optimize observed or reused queries. This makes sure that when you update/insert/remove documents, the query does not have to re-run over the whole database but the new results will be calculated from the events. This creates a huge performance-gain with zero cost. The QueryChangeDetection works internally and is currently in beta (disabled by default).


Imagine you have a very big collection with many user-documents. At your page you want to display a toplist with users which have the most points and are currently logged in. You create a query and subscribe to it.

const query = usersCollection.find().where('loggedIn').eq(true).sort('points');
query.$.subscribe(users => {
    document.querySelector('body').innerHTML = users
        .reduce((prev, cur) => prev + cur.username+ '<br/>', '');

As you may detect, the query can take very long time to run, because you have thousands of users in the collection. When a user now logs off, the whole query will re-run over the database which takes again very long.

anyUser.loggedIn = false;

But not with the QueryChangeDetection enabled. Now, when one user logs off, it will calculate the new results from the current results plus the RxChangeEvent. This often can be done in-memory without making IO-requests to the storage-engine. The QueryChangeDetection not only works on subscribed queries, but also when you do multiple .exec()'s on the same query.

Browser support

All major evergreen browsers and IE11 are supported. Tests automatically run against Firefox and Chrome, and manually in a VirtualBox for IE11 and Edge.

We soon will switch to Browserstack and run automated tests in all major browsers

As RxDB heavily relies on PouchDB, see their browser support for more information. Also do keep in mind that different browsers have different storage limits, especially on mobile devices.

Getting started

Get started now by reading the docs or exploring the example-projects.


Check out how you can contribute to this project.

Follow up

  • Follow RxDB on twitter to not miss the latest enhancements.
  • Join the chat on gitter for discussion.

Thank you

A big Thank you to every contributor of this project.



You can’t perform that action at this time.