Open History to see the last commit
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
68LocalStorage, LocalOnly, and IndexedDB Collections are included in `@tanstack/db` and the framework packages:
69
70- **LocalStorage Collection** - For persistent local data that syncs across browser tabs
71- **LocalOnly Collection** - For temporary in-memory data and UI state
72- **IndexedDB Collection** - For asynchronous browser persistence and structured values
73
74Use `localStorageCollectionOptions`, `localOnlyCollectionOptions`, or `indexedDBCollectionOptions` from `@tanstack/db` or your framework package (e.g., `@tanstack/react-db`).
75
76### IndexedDB Collection
77
78For local browser data stored in IndexedDB, install `@tanstack/db` or a framework package that re-exports it.
79
80Use `createIndexedDB` to open a database, then `indexedDBCollectionOptions` to create Collections for its stores. The [IndexedDB Collection guide](./collections/indexed-db-collection.md) covers setup, mutations, cross-tab synchronization, and connection ownership.
81
82### SQLite Persistence
83
84Use 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:
85
86```sh
87npm install @tanstack/browser-db-sqlite-persistence @journeyapps/wa-sqlite
88```
89
90The [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.
91
92### Offline Transactions
93
94Use `@tanstack/offline-transactions` to retain pending mutations and retry them when the server is available:
95
96```sh
97npm install @tanstack/offline-transactions
98```
99
100The [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.
101
102### Sync Engines
103
104#### Electric Collection
105
106For real-time sync with [ElectricSQL](https://electric-sql.com):
107
108```sh
109npm install @tanstack/electric-db-collection
110```
111
112Use `electricCollectionOptions` to sync data from Postgres databases through ElectricSQL shapes. Ideal for real-time, local-first applications.
113
114#### TrailBase Collection
115
116For syncing with [TrailBase](https://trailbase.io) backends:
117
118```sh
119npm install @tanstack/trailbase-db-collection
120```
121
122Use `trailBaseCollectionOptions` to sync records from TrailBase's Record APIs with built-in subscription support.
123
124#### PowerSync Collection
125
126For offline-first sync with [PowerSync](https://powersync.com):
127
128Use `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:
129
130**Web**
131
132```sh
133npm install @tanstack/powersync-db-collection @powersync/web @journeyapps/wa-sqlite
134```
135
136**React Native**
137
138```sh
139npm install @tanstack/powersync-db-collection @powersync/react-native @powersync/op-sqlite @op-engineering/op-sqlite
140```
141
142Or use `@journeyapps/react-native-quick-sqlite` as an alternative SQLite adapter.
143
144See the [PowerSync Collection documentation](./collections/powersync-collection.md) for setup details.
145
146### RxDB Collection
147
148For offline-first apps and local persistence with [RxDB](https://rxdb.info):
149
150```sh
151npm install @tanstack/rxdb-db-collection
152```
153
154Use `rxdbCollectionOptions` to bridge an [RxDB collection](https://rxdb.info/rx-collection.html) into TanStack DB.
155This gives you reactive TanStack DB collections backed by RxDB's powerful local-first database, replication, and conflict handling features.