Open History to see the last commit
1# trytanstackdb.com _(BETA version)_
2
3> Note that this project is still in its early stages.
4
5An interactive guide for taking the first steps with
6[`@tanstack/tanstack-db`](https://tanstack.com/db/latest/docs/overview) by
7[fuko](fulop.dev/).
8
9[🔗 trytanstackdb.com](https://trytanstackdb.com)
10
11
12
13https://github.com/user-attachments/assets/1d437530-e575-4e52-8db9-2e99a00635a2
14
15
16## TODO
17
18See [TODO.md](./TODO.md).
19
20## 🚀 Main goals, motivations
21
22It took a while for TanStack DB to "click" for me, but it's not because this
23library is too nieche. When I used it for a POC and showed that to my
24colleagues, they seemed to immediately understand the advantages of TanStack DB,
25because I could show exactly the things I explained.
26
27This project aims to bring the same interactive and practical learning
28experience to everybody elseon the internet.
29
30### Target audience
31
32There are two types of people in the target audience of this project:
33
341. Devs, who just heard about TanStack DB, and want to understand what it is,
35 and see if it could be useful for their use cases.
362. _(Future goal):_ People who want to build things with TanStack DB, and want
37 to see a reference implementation of the features it has.
38
39## Architecture
40
41The architecture was designed around the two things that I wanted to highlight
42in the interactive tutorial:
43
441. TanStack DB can make applications feel incredibly fast, even when the network
45 latency is large
462. contrary to conventional local-first approaches, this library doesn't require
47 big technical changes on the back end (works with any database, no need for
48 adding new libs to your backend, simple api endpoints work just fine)
49
50Databases are expensive, so instead of running one on a server, this app uses a
51local Postgres instance in WASM via [PGlite](https://pglite.dev/).
52
53I wanted to make it possible to inspect `fetch` requests in the browser to make
54the syncing mechanisms more observable. That is achieved by a service worker
55that proxies http requests between front end and the API handlers (which are
56also part of the front end).
57
58```mermaid
59sequenceDiagram
60 participant Client
61 participant ServiceWorker as Service Worker (sw.js)
62 participant MainThread as Main Thread (Local API)
63 participant PGlite as PGlite (Local Postgres WASM)
64
65 Client->>ServiceWorker: API call
66 ServiceWorker->>MainThread: Forward request
67 MainThread->>PGlite: Fetch data
68 PGlite->>MainThread: Return data
69 MainThread->>ServiceWorker: Forward response
70 ServiceWorker->>Client: Respond to original request
71```
72
73## Development
74
75See [DEVELOPMENT.md](./DEVELOPMENT.md).