diff --git a/docs-src/SUMMARY.md b/docs-src/SUMMARY.md
index 1a41cfa6b36..788531dbc5a 100644
--- a/docs-src/SUMMARY.md
+++ b/docs-src/SUMMARY.md
@@ -167,6 +167,8 @@
* [Slow IndexedDB](./slow-indexeddb.md)
* [Why NoSQL](./why-nosql.md)
* [Alternatives](./alternatives.md)
+ * [React Native Database](./react-native-database.md)
+ * [Capacitor Database](./capacitor-database.md)
* [Questions & Answers](./questions-answers.md)
diff --git a/docs-src/alternatives.md b/docs-src/alternatives.md
index 92569264fb4..375b9c8a4da 100644
--- a/docs-src/alternatives.md
+++ b/docs-src/alternatives.md
@@ -198,7 +198,7 @@ RxDB supports using [Dexie.js as RxStorage](./rx-storage-dexie.md) which enhance
Originally Realm was a mobile database for Android and iOS. Later they added support for other languages and runtimes, also for JavaScript.
It was meant as replacement for SQLite but is more like an object store then a full SQL database.
In 2019 MongoDB bought Realm and changed the projects focus.
-Now Realm is made for replication with the MongoDB Realm Sync based on the MongoDB Atlas Cloud platform.
+Now Realm is made for replication with the MongoDB Realm Sync based on the MongoDB Atlas Cloud platform. This tight coupling to the MongoDB cloud service is a big downside for most use cases.
### Apollo
diff --git a/docs-src/capacitor-database.md b/docs-src/capacitor-database.md
new file mode 100644
index 00000000000..9a836d95e7f
--- /dev/null
+++ b/docs-src/capacitor-database.md
@@ -0,0 +1,175 @@
+# Capacitor Database
+
+[Capacitor](https://capacitorjs.com/) is an open source native JavaScript runtime to build Web based Native apps. You can use it to create cross-platform iOS, Android, and Progressive Web Apps with the web technologies JavaScript, HTML, and CSS.
+It is developed by the Ionic Team and provides a great alternative to create hybrid apps. Compared to [React Native](./react-native-database.md), Capacitor is more Web-Like because the JavaScript runtime supports most Web APIs like IndexedDB, fetch, and so on.
+
+To read and write persistend data in Capacitor, there are multiple solutions which are shown in the following.
+
+**NOTICE:** You are reading this inside of the [RxDB](https://rxdb.info/) documentation, so everything might be opinionated.
+
+
+
+
+
+
+
+## Database Solutions for Capacitor
+
+
+
+### Preferences API
+
+Capacitor comes with a native [Preferences API](https://capacitorjs.com/docs/apis/preferences) which is a simple, perssistent key->value store for lightweight data, similar to the browsers localstorage or React Native [AsyncStorage](./react-native-database.md#asyncstorage).
+
+To use it, you first have to install it from npm `npm install @capacitor/preferences` and then you can import it and write/read data.
+Notice that all calls to the preferences API are asynchronous so they return a `Promise` that must be `await`-ed.
+
+```ts
+import { Preferences } from '@capacitor/preferences';
+
+
+// write
+await Preferences.set({
+ key: 'foo',
+ value: 'baar',
+});
+
+// read
+const { value } = await Preferences.get({ key: 'foo' }); // > 'bar'
+
+// delete
+await Preferences.remove({ key: 'foo' });
+```
+
+The preferences API is good when only a small amount of data needs to be stored and when no query capabilities besides the key access are required. Complex queries or other features like indexes or replication are not supported which makes the preferences API not suitable for anything more then storing simple data like user settings.
+
+### Localstorage/IndexedDB/WebSQL
+
+Since Capacitor apps run in a web view, Web APIs like IndexedDB, Localstorage and WebSQL are available. But the default browser behavior is to clean up these storages regularly when they are not in use for a long time or the device is low on space. Therefore you cannot 100% rely on the persistence of the stored data and your application needs to expect that the data will be lost eventually.
+
+Storing data in these storages can be done in browsers, because there is no other option. But in Capacitor iOS and Android, you should not rely on these.
+
+### SQLite
+
+SQLite is a SQL based relational database written in C that was crafted to be embed inside of applications. Operations are written in the SQL query language and SQLite generally follows the PostgreSQL syntax.
+
+To use SQLite in Capacitor, there are three options:
+
+- The [@capacitor-community/sqlite](https://github.com/capacitor-community/sqlite) package
+- The [cordova-sqlite-storage](https://github.com/storesafe/cordova-sqlite-storage) package
+- The non-free [Ionic Secure Storage](https://ionic.io/products/secure-storage) which comes at **999$** per month.
+
+
+It is recommended to use the `@capacitor-community/sqlite` because it has the best maintenance and is open source. Install it first `npm install --save @capacitor-community/sqlite` and then set the storage location for iOS apps:
+
+```json
+{
+ "plugins": {
+ "CapacitorSQLite": {
+ "iosDatabaseLocation": "Library/CapacitorDatabase"
+ }
+ }
+}
+```
+
+Now you can create a database connection and use the SQLite database.
+
+```ts
+import { Capacitor } from '@capacitor/core';
+import { CapacitorSQLite, SQLiteDBConnection, SQLiteConnection, capSQLiteSet,
+ capSQLiteChanges, capSQLiteValues, capEchoResult, capSQLiteResult,
+ capNCDatabasePathResult } from '@capacitor-community/sqlite';
+
+const sqlite = new SQLiteConnection(CapacitorSQLite);
+const database: SQLiteDBConnection = await this.sqlite.createConnection(databaseName, encrypted, mode, version, readOnly);
+let { rows } = database.query('SELECT somevalue FROM sometable');
+```
+
+
+The downside of SQLite is that it is lacking many features that are handful when using a database together with an UI based application like your Capacitor app. For example it is not possible to observe queries or document fields. Also there is no realtime replication feature, you can only import json files. This makes SQLite a good solution when you just want to store data on the client, but when you want to sync data with a server or other clients or create big complex realtime applications, you have to use something else.
+
+
+
+### RxDB
+
+
+
+
+
+
+[RxDB](https://rxdb.info/) is an offline first, NoSQL database for JavaScript Applications like hybrid apps. Because it is reactive, you can 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 realtime applications like what you need in Capacitor.
+
+Because RxDB is made for Web applications, most of the [available RxStorage](./rx-storage.md) plugins can be used to store and query data in a Capacitor app. However it is recommended to use the [SQLite RxStorage](./rx-storage-sqlite.md) because it stores the data on the filesystem of the device, not in the JavaScript runtime (like IndexedDB). Storing data on the filesystem ensures it is persistend and will not be cleaned up by any process. Also the performance of SQLite is [much faster](./rx-storage.md#performance-comparison) compared to IndexedDB, because SQLite does not have to go through a browsers permission layers. For the SQLite binding you should use the [@capacitor-community/sqlite](https://github.com/capacitor-community/sqlite) package.
+
+Because the SQLite RxStorage is part of the [Premium Plugins](./premium.md) which must be purchased, it is recommended to use the [Dexie.js RxStorage](./rx-storage-dexie.md) while testing and prototyping your Capacitor app.
+
+
+To use the SQLite RxStorage in Capacitor you have to install all dependencies via `npm install rxdb rxjs rxdb-premium @capacitor-community/sqlite`.
+
+For iOS apps you should add a database location in your Capacitor settings:
+
+```json
+{
+ "plugins": {
+ "CapacitorSQLite": {
+ "iosDatabaseLocation": "Library/CapacitorDatabase"
+ }
+ }
+}
+```
+
+Then you can assemble the RxStorage and create a database with it:
+
+```ts
+import {
+ createRxDatabase
+} from 'rxdb';
+import {
+ getRxStorageSQLite,
+ getSQLiteBasicsCapacitor
+} from 'rxdb-premium/plugins/sqlite';
+import {
+ CapacitorSQLite,
+ SQLiteConnection
+} from '@capacitor-community/sqlite';
+import { Capacitor } from '@capacitor/core';
+const sqlite = new SQLiteConnection(CapacitorSQLite);
+
+// create database
+const myRxDatabase = await createRxDatabase({
+ name: 'exampledb',
+ storage: getRxStorageSQLite({
+ sqliteBasics: getSQLiteBasicsCapacitor(sqlite, Capacitor)
+ })
+});
+
+// create collections
+const collections = await myRxDatabase.addCollections({
+ humans: {
+ /* ... */
+ }
+});
+
+// insert document
+await collections.humans.insert({id: 'foo', name: 'bar'});
+
+// run a query
+const result = await collections.humans.find({
+ selector: {
+ name: 'bar'
+ }
+}).exec();
+
+// observe a query
+await collections.humans.find({
+ selector: {
+ name: 'bar'
+ }
+}).$.subscribe(result => {/* ... */});
+```
+
+
+## Follow up
+
+- If you haven't done yet, you should start learning about RxDB with the [Quickstart Tutorial](./quickstart.md).
+- There is a followup list of other [client side database alternatives](./alternatives.md).
diff --git a/docs-src/electron-database.md b/docs-src/electron-database.md
new file mode 100644
index 00000000000..464090415c4
--- /dev/null
+++ b/docs-src/electron-database.md
@@ -0,0 +1 @@
+# TODO
diff --git a/docs-src/react-native-database.md b/docs-src/react-native-database.md
new file mode 100644
index 00000000000..a58a8ed1504
--- /dev/null
+++ b/docs-src/react-native-database.md
@@ -0,0 +1,218 @@
+# React Native Database
+
+React Native provides a cross-platform JavaScript runtime that runs on different operating systems like Android, iOS, Windows and others. Mostly it is used to create hybrid Apps that run on mobile devices at Android (google) and iOS (apple).
+
+In difference to the JavaScript runtime of browsers, React Native does not support all HTML5 APIs and so it is not possible to use browser storage possibilities like localstorage, cookies, WebSQL or IndexedDB.
+Instead a different storage solution must be chosen that does not come directly with React Native itself but has to be installed as a library or plugin.
+
+**NOTICE:** You are reading this inside of the [RxDB](https://rxdb.info/) documentation, so everything might be opinionated.
+
+
+
+
+
+## Database Solutions for React-Native
+
+There are multiple database solutions that can be used with React Native. While I would recommend to use [RxDB](./) for most use cases, it is still helpful to learn about other alternatives.
+
+### AsyncStorage
+
+AsyncStorage is a key->value storage solution that works similar to the browsers *localstorage* API. The big difference is that access to the AsyncStorage is not a blocking operation but instead everything is `Promise` based. This is a big benefit because long running writes and reads will not block your JavaScript process which would cause a laggy user interface.
+
+```ts
+/**
+ * Because it is Promise-based,
+ * you have to 'await' the call to getItem()
+ */
+await setItem('myKey', 'myValue');
+const value = await AsyncStorage.getItem('myKey');
+```
+
+
+AsyncStorage was originally included in [React Native itself](https://reactnative.dev/docs/asyncstorage). But it was deprecated by the React Native Team which recommends to use a community based package instead. There is a [community fork of AsyncStorage](https://github.com/react-native-async-storage/async-storage) that is actively maintained and open source.
+
+AsyncStorage is fine when only a small amount of data needs to be stored and when no query capabilities besides the key-access are required. Complex queries or features are not supported which makes AsyncStorage not suitable for anything more then storing simple user settings data.
+
+
+### SQLite
+
+SQLite is a SQL based relational database written in C that was crafted to be embed inside of applications. Operations are written in the SQL query language and SQLite generally follows the PostgreSQL syntax.
+
+To use SQLite in React Native, you first have to include the SQLite library itself as a plugin. There a different project out there that that can be used, but I would recommend to use the [react-native-quick-sqlite](https://github.com/ospfranco/react-native-quick-sqlite) project.
+
+First you have to install the library into your React Native project via `npm install react-native-quick-sqlite`.
+In your code you can then import the library and create a database connection:
+
+```ts
+import {open} from 'react-native-quick-sqlite';
+const db = open('myDb.sqlite');
+```
+
+Notice that SQLite is a file based database where all data is stored directly in the filesystem of the OS. Therefore to create a connection, you have to provide a filename.
+
+With the open connection you can then run SQL queries:
+
+```ts
+let { rows } = db.execute('SELECT somevalue FROM sometable');
+```
+
+If that does not work for you, you might want to try the [react-native-sqlite-storage](https://github.com/andpor/react-native-sqlite-storage) project instead which is also very popular.
+
+The downside of SQLite is that it is lacking many features that are handful when using a database together with an UI based application. For example it is not possible to observe queries or document fields.
+Also there is no replication method. This makes SQLite a good solution when you want to solely store data on the client, but not when you want to sync data with a server or other clients.
+
+### PouchDB
+
+
+
+
+
+PouchDB is a JavaScript NoSQL database that follows the API of the [Apache CouchDB](https://couchdb.apache.org/) server database.
+The core feature of PouchDB is the ability to do a two-way replication with any CouchDB compliant endpoint.
+While PouchDB is pretty mature, it has some drawbacks that makes blocks it from being used in a client-side React Native application. For example it has to store all documents states over time which is required to replicate with CouchDB. Also it is not easily possible to fully purge documents and so it will fill up disc space over time. A big problem is also that PouchDB is not really maintained and major bugs like wrong query results are not fixed anymore. The performance of PouchDB is a general bottleneck which is caused by how it has to store and fetch documents while being compliant to CouchDB. The only real reason to use PouchDB in React Native, is when you want to replicate with a CouchDB or Couchbase server.
+
+Because PouchDB is based on an adapter system for storage, there are two options to use it with React Native:
+
+- Either use the [pouchdb-adapter-react-native-sqlite](https://github.com/craftzdog/pouchdb-react-native) adapter
+- or the [pouchdb-adapter-asyncstorage](pouchdb-adapter-asyncstorage) adapter.
+
+Because the `asyncstorage` adapter is no longer maintained, it is recommended to use the `native-sqlite` adapter:
+
+First you have to install the adapter and other dependencies via `npm install pouchdb-adapter-react-native-sqlite react-native-quick-sqlite react-native-quick-websql`.
+
+Then you have to craft a custom PouchDB class that combines these plugins:
+
+```ts
+import 'react-native-get-random-values';
+import PouchDB from 'pouchdb-core';
+import HttpPouch from 'pouchdb-adapter-http';
+import replication from 'pouchdb-replication';
+import mapreduce from 'pouchdb-mapreduce';
+import SQLiteAdapterFactory from 'pouchdb-adapter-react-native-sqlite';
+import WebSQLite from 'react-native-quick-websql';
+
+const SQLiteAdapter = SQLiteAdapterFactory(WebSQLite);
+export default PouchDB.plugin(HttpPouch)
+ .plugin(replication)
+ .plugin(mapreduce)
+ .plugin(SQLiteAdapter);
+```
+
+This can then be used to create a PouchDB database instance which can store and query documents:
+
+```ts
+const db = new PouchDB('mydb.db', {
+ adapter: 'react-native-sqlite'
+});
+```
+
+
+### RxDB
+
+
+
+
+
+[RxDB](https://rxdb.info/) is an offline-first, NoSQL-database for JavaScript Applications. It is reactive which 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 realtime applications like what you need in React Native.
+
+There are multiple ways to use RxDB in React Native:
+
+- Use the [memory RxStorage](./rx-storage-memory.md) that stores the data inside of the JavaScript memory without persistence
+- Use the [LokiJS RxStorage](./rx-storage-lokijs.md) with the [react-native-lokijs](https://github.com/cawfree/react-native-lokijs) plugin
+- Use the [PouchDB RxStorage](./rx-storage-pouchdb.md) with the SQLite plugin mentioned above.
+- Use the [SQLite RxStorage](./rx-storage-sqlite.md) with the [react-native-quick-sqlite](https://github.com/ospfranco/react-native-quick-sqlite) plugin.
+
+It is recommended to use the [SQLite RxStorage](./rx-storage-sqlite.md) because it has the best performance and is the easiest to set up. However it is part of the [Premium Plugins](./premium.md) which must be purchased, so to try out RxDB with React Native, you might want to use one of the other three options.
+
+First you have to install all dependencies via `npm install rxdb rxjs rxdb-premium react-native-quick-sqlite`.
+Then you can assemble the RxStorage and create a database with it:
+
+```ts
+import {
+ createRxDatabase
+} from 'rxdb';
+import {
+ getRxStorageSQLite,
+ getSQLiteBasicsQuickSQLite
+} from 'rxdb-premium/plugins/sqlite';
+import { openDatabase } from 'react-native-quick-sqlite';
+
+// create database
+const myRxDatabase = await createRxDatabase({
+ name: 'exampledb',
+ storage: getRxStorageSQLite({
+ sqliteBasics: getSQLiteBasicsQuickSQLite(openDatabase)
+ })
+});
+
+// create collections
+const collections = await myRxDatabase.addCollections({
+ humans: {
+ /* ... */
+ }
+});
+
+// insert document
+await collections.humans.insert({id: 'foo', name: 'bar'});
+
+// run a query
+const result = await collections.humans.find({
+ selector: {
+ name: 'bar'
+ }
+}).exec();
+
+// observe a query
+await collections.humans.find({
+ selector: {
+ name: 'bar'
+ }
+}).$.subscribe(result => {/* ... */});
+```
+
+Using the SQLite RxStorage is pretty fast, which is shown in the [performance comparison](./rx-storage.md#performance-comparison).
+
+### WatermelonDB
+
+WatermelonDB reactive and asynchronous database for React and React Native apps. It is based on SQLite in React Native and LokiJS when it is used in the browser. It supports schemas, observable queries, migrations and relations.
+The schema layout is handled by TypeScript decorators and looks like this:
+
+```ts
+class Post extends Model {
+ @field('name') name;
+ @field('body') body;
+ @children('comments') comments;
+
+ // a relation to another table
+ @relation('users', 'author_id') author;
+}
+```
+
+WatermelonDB also [supports replication](https://nozbe.github.io/WatermelonDB/Advanced/Sync.html) but the sync protocol is pretty complex because on how it resolves conflicts. I recommend to watch [this video](https://www.youtube.com/watch?v=uFvHURTRLxQ) to learn how the replication works.
+
+According to the roadmap, despite being essentially feature-complete, WatermelonDB is still on the `0.xx` version and intends to switch to a `1.x.x` version as once it [reaches a long-term stable API](https://nozbe.github.io/WatermelonDB/Roadmap.html).
+
+### Firebase / Firestore
+
+
+
+
+
+Firestore is a cloud based database technologie that stores data on clients devices and replicates it with the Firebase cloud service that is run by google. It has many features like observability and authentication.
+The main lacking feature is the non-complete offline first support because clients cannot start the application while being offline because then the authentication does not work. After they are authenticated, being offline is no longer a problem.
+Also using firestore creates a vendor lock-in because it is not possible to replicate with a custom self hosted backend.
+
+To get started with Firestore in React Native, it is recommended to use the [React Native Firebase](https://github.com/invertase/react-native-firebase) open-source project.
+
+
+
+
+
+## Follow up
+
+- If you haven't done yet, you should start learning about RxDB with the [Quickstart Tutorial](./quickstart.md).
+- There is a followup list of other [client side database alternatives](./alternatives.md).
diff --git a/docs-src/replication.md b/docs-src/replication.md
index 79e98c0ce18..a896462df93 100644
--- a/docs-src/replication.md
+++ b/docs-src/replication.md
@@ -1,4 +1,4 @@
-# Replication
+# Database Replication
The RxDB replication protocol provides the ability to replicate the database state in **realtime** between the clients and the server.
diff --git a/examples/ionic2/README.md b/examples/ionic2/README.md
index 0c7f0896de6..119c0bda948 100644
--- a/examples/ionic2/README.md
+++ b/examples/ionic2/README.md
@@ -24,3 +24,8 @@ $ ionic cordova run ios
Substitute ios for android if not on a Mac.
+
+
+## Related
+
+- [Comparison of Capacitor Databases](https://rxdb.info/capacitor-database.html)
diff --git a/examples/react-native/README.md b/examples/react-native/README.md
index 5bb162e3e8d..f259d867537 100644
--- a/examples/react-native/README.md
+++ b/examples/react-native/README.md
@@ -22,3 +22,8 @@ For database replication and syncing you will need to input a public ip address


+
+
+## Related
+
+- [Comparison of React Native Databases](https://rxdb.info/react-native-database.html)
diff --git a/test/unit/replication-p2p.test.ts b/test/unit/replication-p2p.test.ts
index 3b8a9723c27..71383280632 100644
--- a/test/unit/replication-p2p.test.ts
+++ b/test/unit/replication-p2p.test.ts
@@ -33,10 +33,7 @@ describe('replication-p2p.test.ts', () => {
return;
}
- if (
- config.storage.name === 'lokijs' &&
- !config.platform.isNode()
- ) {
+ if (config.storage.name === 'lokijs') {
/**
* TODO for whatever reason this test
* randomly does not work in the browser with lokijs