Skip to content

Commit 486a182

Browse files
committed
ADD RxDB Tanstack FAQ
1 parent 05130f2 commit 486a182

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

docs/collections/rxdb-collection.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The `@tanstack/rxdb-db-collection` package allows you to create collections that
2222

2323
## 1. Installation
2424

25-
Install the RXDB collection packages along with your preferred framework integration.
25+
Install the RxDB collection packages along with your preferred framework integration.
2626

2727
```bash
2828
npm install @tanstack/rxdb-db-collection rxdb @tanstack/react-db
@@ -132,3 +132,36 @@ Replication and sync in RxDB run independently of TanStack DB. You set up replic
132132
When replication runs, it pulls and pushes changes to the backend and applies them to the RxDB collection. Since the TanStack DB integration subscribes to the RxDB change stream, any changes applied by replication are automatically reflected in your TanStack DB collection.
133133

134134
This separation of concerns means you configure replication entirely in RxDB, and TanStack DB automatically benefits: your TanStack collections always stay up to date with whatever sync strategy you choose.
135+
136+
137+
## FAQ
138+
139+
### Do I still need RxDB schema indexes if I only query TanStack DB?
140+
141+
Usually not for TanStack DB queries themselves. TanStack DB queries run entirely in memory, so RxDB schema indexes do not affect the performance of TanStack DB's live queries. However, RxDB indexes may still be important if:
142+
- You run queries directly against RxDB (e.g. `rxCollection.find(...)`).
143+
- Your replication setup uses filtered queries or selectors.
144+
- You rely on RxDB to selectively load subsets of data instead of hydrating everything into memory.
145+
146+
### Is data duplicated between RxDB and TanStack DB?
147+
148+
Yes, intentionally. RxDB stores data durably on disk. TanStack DB stores data in memory for fast queries and reactivity. This duplication enables high-performance UI queries while retaining [local-first](https://rxdb.info/articles/local-first-future.html) persistence and sync.
149+
150+
### How does backend ↔ RxDB ↔ TanStack DB synchronization work?
151+
152+
Synchronization follows a clear separation of responsibilities between RxDB and TanStack DB.
153+
154+
**RxDB** is responsible for persistence and networking. It stores data durably using a local storage engine (IndexedDB, SQLite, etc.) and handles all replication logic. Replication is configured directly on the RxDB collection and runs independently of TanStack DB. RxDB pulls changes from the backend, applies them locally, resolves conflicts, and pushes local changes back to the backend.
155+
156+
**TanStack DB** sits on top as an in-memory, reactive query layer. It does not talk to the backend directly and does not participate in replication. Instead, it mirrors the current state of the RxDB collection in memory and provides fast live queries and optimistic mutations for the UI.
157+
158+
This design intentionally forms two independent loops:
159+
- A durability and sync loop managed entirely by RxDB (backend to RxDB).
160+
- A reactive UI loop managed by TanStack DB (RxDB change stream to in-memory collections to live queries).
161+
162+
## Learn More
163+
164+
- [RxDB Documentation](https://rxdb.info/overview.html)
165+
- [RxDB Sync Engine](https://rxdb.info/replication.html)
166+
- [Tanstack DB Live Queries](https://tanstack.com/db/latest/docs/guides/live-queries)
167+

0 commit comments

Comments
 (0)