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

installation.md

128 lines3.2 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 v16.8+
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### Sync Engines
76​
77#### Electric Collection
78​
79For real-time sync with [ElectricSQL](https://electric-sql.com):
80​
81```sh
82npm install @tanstack/electric-db-collection
83```
84​
85Use `electricCollectionOptions` to sync data from Postgres databases through ElectricSQL shapes. Ideal for real-time, local-first applications.
86​
87#### TrailBase Collection
88​
89For syncing with [TrailBase](https://trailbase.io) backends:
90​
91```sh
92npm install @tanstack/trailbase-db-collection
93```
94​
95Use `trailBaseCollectionOptions` to sync records from TrailBase's Record APIs with built-in subscription support.
96​
97#### PowerSync Collection
98​
99For offline-first sync with [PowerSync](https://powersync.com):
100​
101Use `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:
102​
103**Web**
104​
105```sh
106npm install @tanstack/powersync-db-collection @powersync/web @journeyapps/wa-sqlite
107```
108​
109**React Native**
110​
111```sh
112npm install @tanstack/powersync-db-collection @powersync/react-native @powersync/op-sqlite @op-engineering/op-sqlite
113```
114​
115Or use `@journeyapps/react-native-quick-sqlite` as an alternative SQLite adapter.
116​
117See the [PowerSync Collection documentation](./collections/powersync-collection.md) for setup details.
118​
119### RxDB Collection
120​
121For offline-first apps and local persistence with [RxDB](https://rxdb.info):
122​
123```sh
124npm install @tanstack/rxdb-db-collection
125```
126​
127Use `rxdbCollectionOptions` to bridge an [RxDB collection](https://rxdb.info/rx-collection.html) into TanStack DB.
128This gives you reactive TanStack DB collections backed by RxDB's powerful local-first database, replication, and conflict handling features.