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## Preact
17
18```sh
19npm install @tanstack/preact-db
20```
21
22TanStack DB is compatible with Preact v10+
23
24## Solid
25
26```sh
27npm install @tanstack/solid-db
28```
29
30## Svelte
31
32```sh
33npm install @tanstack/svelte-db
34```
35
36## Vue
37
38```sh
39npm install @tanstack/vue-db
40```
41
42TanStack DB is compatible with Vue v3.3.0+
43
44## Angular
45
46```sh
47npm install @tanstack/angular-db
48```
49
50TanStack DB is compatible with Angular v16.0.0+
51
52## Vanilla JS
53
54```sh
55npm install @tanstack/db
56```
57
58Install the the core `@tanstack/db` package to use DB without a framework.
59
60## Collection Packages
61
62TanStack DB also provides specialized collection packages for different data sources and storage needs:
63
64### Query Collection
65
66For loading data using TanStack Query:
67
68```sh
69npm install @tanstack/query-db-collection
70```
71
72Use `queryCollectionOptions` to fetch data into collections using TanStack Query. This is perfect for REST APIs and existing TanStack Query setups.
73
74### Local Collections
75
76LocalStorage, LocalOnly, and IndexedDB Collections are included in `@tanstack/db` and the framework packages:
77
78- **LocalStorage Collection** - For persistent local data that syncs across browser tabs
79- **LocalOnly Collection** - For temporary in-memory data and UI state
80- **IndexedDB Collection** - For asynchronous browser persistence and structured values
81
82Use `localStorageCollectionOptions`, `localOnlyCollectionOptions`, or `indexedDBCollectionOptions` from `@tanstack/db` or your framework package (e.g., `@tanstack/react-db`).
83
84### IndexedDB Collection
85
86For local browser data stored in IndexedDB, install `@tanstack/db` or a framework package that re-exports it.
87
88Use `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.
89
90### SQLite Persistence
91
92Use 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:
93
94```sh
95npm install @tanstack/browser-db-sqlite-persistence @journeyapps/wa-sqlite
96```
97
98The [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.
99
100### Offline Transactions
101
102Use `@tanstack/offline-transactions` to retain pending mutations and retry them when the server is available:
103
104```sh
105npm install @tanstack/offline-transactions
106```
107
108The [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.
109
110### Sync Engines
111
112#### Electric Collection
113
114For real-time sync with [ElectricSQL](https://electric-sql.com):
115
116```sh
117npm install @tanstack/electric-db-collection
118```
119
120Use `electricCollectionOptions` to sync data from Postgres databases through ElectricSQL shapes. Ideal for real-time, local-first applications.
121
122#### TrailBase Collection
123
124For syncing with [TrailBase](https://trailbase.io) backends:
125
126```sh
127npm install @tanstack/trailbase-db-collection
128```
129
130Use `trailBaseCollectionOptions` to sync records from TrailBase's Record APIs with built-in subscription support.
131
132#### PowerSync Collection
133
134For offline-first sync with [PowerSync](https://powersync.com):
135
136Use `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:
137
138**Web**
139
140```sh
141npm install @tanstack/powersync-db-collection @powersync/web @journeyapps/wa-sqlite
142```
143
144**React Native**
145
146```sh
147npm install @tanstack/powersync-db-collection @powersync/react-native @powersync/op-sqlite @op-engineering/op-sqlite
148```
149
150Or use `@journeyapps/react-native-quick-sqlite` as an alternative SQLite adapter.
151
152See the [PowerSync Collection documentation](./collections/powersync-collection.md) for setup details.
153
154### RxDB Collection
155
156For offline-first apps and local persistence with [RxDB](https://rxdb.info):
157
158```sh
159npm install @tanstack/rxdb-db-collection
160```
161
162Use `rxdbCollectionOptions` to bridge an [RxDB collection](https://rxdb.info/rx-collection.html) into TanStack DB.
163This gives you reactive TanStack DB collections backed by RxDB's powerful local-first database, replication, and conflict handling features.