RxDB

适用于 JavaScript 应用程序的快速、本地优先、反应型数据库。「A fast, local first, reactive Database for JavaScript Applications」

Github stars Tracking Chart

Announcement
             Version 16.0.0 is now released, read the CHANGELOG               

Use the quickstart, read the documentation or explore the example projects.

RxDB is a proven technology used by thousands of developers worldwide. With its flexibility, RxDB is used in a diverse range of apps and services.

realtime.gif

RxDB provides an easy to implement, battle-tested replication protocol for realtime sync 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 or NATS.

RxDB is based on a storage interface 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 IndexedDB, OPFS, LokiJS, Dexie.js, in-memory, SQLite, in a WebWorker thread and even on top of FoundationDB and DenoKV.

No matter what kind of runtime you have, as long as it runs JavaScript, it can run RxDB:

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.

Install

npm install rxdb rxjs --save

Store data

import { 
  createRxDatabase
} from 'rxdb/plugins/core';

/**
 * For browsers, we use the dexie.js based storage
 * which stores data in IndexedDB in the browser.
 * In other JavaScript runtimes, we can use different storages:
 * @link https://rxdb.info/rx-storage.html
 */
import { getRxStorageDexie } from 'rxdb/plugins/storage-dexie';

// create a database
const db = await createRxDatabase({
    name: 'heroesdb', // the name of the database
    storage: getRxStorageDexie()
});

// add collections
await db.addCollections({
  heroes: {
    schema: mySchema
  }
});

// insert a document
await db.heroes.insert({
  name: 'Bob',
  healthpoints: 100
});

Query data once

const aliveHeroes = await db.heroes.find({
  selector: {
    healthpoints: {
      $gt: 0
    }
  }
}).exec(); // the exec() returns the result once

Observe a Query

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 now by reading the docs or exploring the example-projects.

More content

Angular Database, Frontend Database, localStorage, React Database, Browser Database, React Native Database, PWA Database, In-memory NoSQL database, JSON database, Angular IndexedDB, React IndexedDB, Optimistic UI, local database, React Native Encryption

Main metrics

Overview
Name With Ownerpubkey/rxdb
Primary LanguageTypeScript
Program languageJavaScript (Language Count: 6)
Platform
License:Apache License 2.0
所有者活动
Created At2016-12-02 19:34:42
Pushed At2025-04-19 01:50:03
Last Commit At2025-04-19 01:49:09
Release Count496
Last Release Name16.11.0 (Posted on )
First Release Name6.0.0 (Posted on )
用户参与
Stargazers Count22.3k
Watchers Count206
Fork Count1.1k
Commits Count12.7k
Has Issues Enabled
Issues Count787
Issue Open Count4
Pull Requests Count5538
Pull Requests Open Count6
Pull Requests Close Count661
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private