Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

installation.md

158 lines4.4 KB

1---
2title: Installation
3id: installation
4---
5​
6Each supported framework comes with its own package. Each framework package re-exports everything from the core `@tanstack/db` package.
7​
8## React
9​
10```sh
11npm install @tanstack/react-db
12```
13​
14TanStack DB is compatible with React v18+
15​
16## Solid
17​
18```sh
19npm install @tanstack/solid-db
20```
21​
22## Svelte
23​
24```sh
25npm install @tanstack/svelte-db
26```
27​
28## Vue
29​
30```sh
31npm install @tanstack/vue-db
32```
33​
34TanStack DB is compatible with Vue v3.3.0+
35​
36## Angular
37​
38```sh
39npm install @tanstack/angular-db
40```
41​
42TanStack DB is compatible with Angular v16.0.0+
43​
44## Vanilla JS
45​
46```sh
47npm install @tanstack/db
48```
49​
50Install the the core `@tanstack/db` package to use DB without a framework.
51​
52## Collection Packages
53​
54TanStack DB also provides specialized collection packages for different data sources and storage needs:
55​
56### Query Collection
57​
58For loading data using TanStack Query:
59​
60```sh
61npm install @tanstack/query-db-collection
62```
63​
64Use `queryCollectionOptions` to fetch data into collections using TanStack Query. This is perfect for REST APIs and existing TanStack Query setups.
65​
66### Local Collections
67​
68Local storage and in-memory collections are included with the framework packages:
69​
70- **LocalStorageCollection** - For persistent local data that syncs across browser tabs
71- **LocalOnlyCollection** - For temporary in-memory data and UI state
72​
73Both use `localStorageCollectionOptions` and `localOnlyCollectionOptions` respectively, available from your framework package (e.g., `@tanstack/react-db`).
74​
75### IndexedDB Collection
76​
77For local browser data stored in IndexedDB:
78​
79```sh
80npm install @tanstack/indexeddb-db-collection
81```
82​
83Use `createIndexedDB` to open a database, then `indexedDBCollectionOptions` to create Collections for its stores. The [IndexedDB Collection guide](./collections/indexeddb-collection.md) covers setup, mutations, cross-tab synchronization, and connection ownership.
84​
85### SQLite Persistence
86​
87Use a runtime package to save Collection rows in SQLite and load them after an app restart. For a browser app, install the OPFS wrapper and its SQLite engine:
88​
89```sh
90npm install @tanstack/browser-db-sqlite-persistence @journeyapps/wa-sqlite
91```
92​
93The [SQLite Persistence guide](./guides/sqlite-persistence.md) shows the browser setup and lists the mobile, desktop, server, and Durable Object packages. It also explains how to wrap an existing sync adapter.
94​
95### Offline Transactions
96​
97Use `@tanstack/offline-transactions` to retain pending mutations and retry them when the server is available:
98​
99```sh
100npm install @tanstack/offline-transactions
101```
102​
103The [Offline Transactions guide](./guides/offline-transactions.md) covers web and React Native setup. It also shows how to use the outbox with a SQLite-persisted Collection.
104​
105### Sync Engines
106​
107#### Electric Collection
108​
109For real-time sync with [ElectricSQL](https://electric-sql.com):
110​
111```sh
112npm install @tanstack/electric-db-collection
113```
114​
115Use `electricCollectionOptions` to sync data from Postgres databases through ElectricSQL shapes. Ideal for real-time, local-first applications.
116​
117#### TrailBase Collection
118​
119For syncing with [TrailBase](https://trailbase.io) backends:
120​
121```sh
122npm install @tanstack/trailbase-db-collection
123```
124​
125Use `trailBaseCollectionOptions` to sync records from TrailBase's Record APIs with built-in subscription support.
126​
127#### PowerSync Collection
128​
129For offline-first sync with [PowerSync](https://powersync.com):
130​
131Use `powerSyncCollectionOptions` to sync data via PowerSync's SQLite-based database with real-time synchronization to PostgreSQL, MongoDB, and MySQL backends. Install the collection package plus the platform-specific PowerSync SDK and SQLite adapter:
132​
133**Web**
134​
135```sh
136npm install @tanstack/powersync-db-collection @powersync/web @journeyapps/wa-sqlite
137```
138​
139**React Native**
140​
141```sh
142npm install @tanstack/powersync-db-collection @powersync/react-native @powersync/op-sqlite @op-engineering/op-sqlite
143```
144​
145Or use `@journeyapps/react-native-quick-sqlite` as an alternative SQLite adapter.
146​
147See the [PowerSync Collection documentation](./collections/powersync-collection.md) for setup details.
148​
149### RxDB Collection
150​
151For offline-first apps and local persistence with [RxDB](https://rxdb.info):
152​
153```sh
154npm install @tanstack/rxdb-db-collection
155```
156​
157Use `rxdbCollectionOptions` to bridge an [RxDB collection](https://rxdb.info/rx-collection.html) into TanStack DB.
158This gives you reactive TanStack DB collections backed by RxDB's powerful local-first database, replication, and conflict handling features.