Skip to content

Commit 4cab99f

Browse files
feat: support for solid-js (#92)
Co-authored-by: Kyle Mathews <[email protected]>
1 parent 0f1c37d commit 4cab99f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+11927
-59
lines changed

.changeset/slick-aliens-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tanstack/solid-db": patch
3+
---
4+
5+
Add initial version of solid-db integration TanStack DB with SolidJS

docs/collection-options-creator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Every collection options creator must implement these key responsibilities:
3232
Define a configuration interface that extends or includes standard collection properties:
3333

3434
```typescript
35-
// Pattern A: User provides handlers (Query / Electric SQL style)
35+
// Pattern A: User provides handlers (Query / ElectricSQL style)
3636
interface MyCollectionConfig<TItem extends object> {
3737
// Your sync engine specific options
3838
connectionUrl: string
@@ -155,7 +155,7 @@ interface MyCollectionConfig<TItem, TRecord> {
155155

156156
There are two distinct patterns for handling mutations in collection options creators:
157157

158-
#### Pattern A: User-Provided Handlers (Electric SQL, Query)
158+
#### Pattern A: User-Provided Handlers (ElectricSQL, Query)
159159

160160
The user provides mutation handlers in the config. Your collection creator passes them through:
161161

examples/react/todo/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
- Move Collections to their own packages ([#252](https://github.com/TanStack/db/pull/252))
116116

117117
- Move local-only and local-storage collections to main `@tanstack/db` package
118-
- Create new `@tanstack/electric-db-collection` package for Electric SQL integration
118+
- Create new `@tanstack/electric-db-collection` package for ElectricSQL integration
119119
- Create new `@tanstack/query-db-collection` package for TanStack Query integration
120120
- Delete `@tanstack/db-collections` package (removed from repo)
121121
- Update example app and documentation to use new package structure

examples/react/todo/src/routes/__root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const Route = createRootRoute({
1818
content: `width=device-width, initial-scale=1`,
1919
},
2020
{
21-
title: `TanStack DB Example`,
21+
title: `TanStack React DB Example`,
2222
},
2323
],
2424
links: [

examples/react/todo/src/routes/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ function HomePage() {
99
<div className="min-h-screen flex items-center justify-center bg-gray-50">
1010
<div className="max-w-md w-full bg-white rounded-lg shadow-lg p-8">
1111
<h1 className="text-3xl font-bold text-center mb-8 text-gray-800">
12-
TanStack DB Demo
12+
TanStack React DB Demo
1313
</h1>
1414

1515
<p className="text-gray-600 text-center mb-8">
16-
Choose a collection type to see how TanStack DB works with different
17-
data sources:
16+
Choose a collection type to see how TanStack React DB works with
17+
different data sources:
1818
</p>
1919

2020
<div className="space-y-4">
@@ -30,7 +30,7 @@ function HomePage() {
3030
<button className="w-full px-6 py-4 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors text-left">
3131
<div className="font-semibold">Electric Collections</div>
3232
<div className="text-sm opacity-90 mt-1">
33-
Real-time sync with Electric SQL
33+
Real-time sync with ElectricSQL
3434
</div>
3535
</button>
3636
</Link>
@@ -45,8 +45,8 @@ function HomePage() {
4545
</div>
4646

4747
<div className="mt-8 text-xs text-center text-gray-500">
48-
Both examples use the same API and UI components, showcasing the
49-
unified interface of TanStack DB.
48+
All examples use the same API and UI components, showcasing the
49+
unified interface of TanStack React DB.
5050
</div>
5151
</div>
5252
</div>

examples/solid/todo/CHANGELOG.md

Lines changed: 310 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
# examples/react/todo
2+
3+
## 0.0.33
4+
5+
### Patch Changes
6+
7+
- Updated dependencies []:
8+
- @tanstack/electric-db-collection@0.0.9
9+
- @tanstack/query-db-collection@0.0.9
10+
- @tanstack/react-db@0.0.27
11+
- @tanstack/trailbase-db-collection@0.0.3
12+
13+
## 0.0.32
14+
15+
### Patch Changes
16+
17+
- Add initial release of TrailBase collection for TanStack DB. TrailBase is a blazingly fast, open-source alternative to Firebase built on Rust, SQLite, and V8. It provides type-safe REST and realtime APIs with sub-millisecond latencies, integrated authentication, and flexible access control - all in a single executable. This collection type enables seamless integration with TrailBase backends for high-performance real-time applications. ([#228](https://github.com/TanStack/db/pull/228))
18+
19+
- Updated dependencies [[`09c6995`](https://github.com/TanStack/db/commit/09c6995ea9c8e6979d077ca63cbdd6215054ae78)]:
20+
- @tanstack/trailbase-db-collection@0.0.2
21+
- @tanstack/electric-db-collection@0.0.8
22+
- @tanstack/query-db-collection@0.0.8
23+
- @tanstack/react-db@0.0.26
24+
25+
## 0.0.31
26+
27+
### Patch Changes
28+
29+
- Updated dependencies [[`20f810e`](https://github.com/TanStack/db/commit/20f810e13a7d802bf56da6f0df89b34312ebb2fd)]:
30+
- @tanstack/electric-db-collection@0.0.7
31+
- @tanstack/query-db-collection@0.0.7
32+
- @tanstack/react-db@0.0.25
33+
34+
## 0.0.30
35+
36+
### Patch Changes
37+
38+
- Updated dependencies []:
39+
- @tanstack/electric-db-collection@0.0.6
40+
- @tanstack/query-db-collection@0.0.6
41+
- @tanstack/react-db@0.0.24
42+
43+
## 0.0.29
44+
45+
### Patch Changes
46+
47+
- Updated dependencies []:
48+
- @tanstack/electric-db-collection@0.0.5
49+
- @tanstack/query-db-collection@0.0.5
50+
- @tanstack/react-db@0.0.23
51+
52+
## 0.0.28
53+
54+
### Patch Changes
55+
56+
- Updated dependencies []:
57+
- @tanstack/electric-db-collection@0.0.4
58+
- @tanstack/query-db-collection@0.0.4
59+
- @tanstack/react-db@0.0.22
60+
61+
## 0.0.27
62+
63+
### Patch Changes
64+
65+
- Move Collections to their own packages ([#252](https://github.com/TanStack/db/pull/252))
66+
67+
- Move local-only and local-storage collections to main `@tanstack/db` package
68+
- Create new `@tanstack/electric-db-collection` package for ElectricSQL integration
69+
- Create new `@tanstack/query-db-collection` package for TanStack Query integration
70+
- Delete `@tanstack/db-collections` package (removed from repo)
71+
- Update example app and documentation to use new package structure
72+
73+
Why?
74+
75+
- Better separation of concerns
76+
- Independent versioning for each collection type
77+
- Cleaner dependencies (electric collections don't need query deps, etc.)
78+
- Easier to add more collection types moving forward
79+
80+
- Updated dependencies [[`8e23322`](https://github.com/TanStack/db/commit/8e233229b25eabed07cdaf12948ba913786bf4f9)]:
81+
- @tanstack/electric-db-collection@0.0.3
82+
- @tanstack/query-db-collection@0.0.3
83+
- @tanstack/react-db@0.0.21
84+
85+
## 0.0.26
86+
87+
### Patch Changes
88+
89+
- Updated dependencies []:
90+
- @tanstack/db-collections@0.0.24
91+
- @tanstack/react-db@0.0.20
92+
93+
## 0.0.25
94+
95+
### Patch Changes
96+
97+
- - [Breaking change for the Electric Collection]: Use numbers for txid ([#245](https://github.com/TanStack/db/pull/245))
98+
- misc type fixes
99+
- Updated dependencies [[`9f0b0c2`](https://github.com/TanStack/db/commit/9f0b0c28ede99273eb5914be28aff55b91c50778)]:
100+
- @tanstack/db-collections@0.0.23
101+
- @tanstack/react-db@0.0.19
102+
103+
## 0.0.24
104+
105+
### Patch Changes
106+
107+
- Updated dependencies [[`266bd29`](https://github.com/TanStack/db/commit/266bd29514c6c0fa9e903986ca11c5e22f4d2361)]:
108+
- @tanstack/db-collections@0.0.22
109+
- @tanstack/react-db@0.0.18
110+
111+
## 0.0.23
112+
113+
### Patch Changes
114+
115+
- Updated dependencies [[`1c9e867`](https://github.com/TanStack/db/commit/1c9e8676405b71a45831456c7119420975ae1456)]:
116+
- @tanstack/db-collections@0.0.21
117+
- @tanstack/react-db@0.0.17
118+
119+
## 0.0.22
120+
121+
### Patch Changes
122+
123+
- Updated dependencies [[`e478d53`](https://github.com/TanStack/db/commit/e478d5353cc8fc64e3a29dda1f86fba863cf6ce8)]:
124+
- @tanstack/react-db@0.0.16
125+
- @tanstack/db-collections@0.0.20
126+
127+
## 0.0.21
128+
129+
### Patch Changes
130+
131+
- Updated dependencies [[`0912a7c`](https://github.com/TanStack/db/commit/0912a7c165325e6981f0b702c169004e08d57f75)]:
132+
- @tanstack/db-collections@0.0.19
133+
- @tanstack/react-db@0.0.15
134+
135+
## 0.0.20
136+
137+
### Patch Changes
138+
139+
- Updated dependencies [[`0dede0a`](https://github.com/TanStack/db/commit/0dede0ab75e66df9797d5c898defdc66685c6f91)]:
140+
- @tanstack/db-collections@0.0.18
141+
142+
## 0.0.19
143+
144+
### Patch Changes
145+
146+
- Updated dependencies []:
147+
- @tanstack/db-collections@0.0.17
148+
- @tanstack/react-db@0.0.14
149+
150+
## 0.0.18
151+
152+
### Patch Changes
153+
154+
- Updated dependencies [[`945868e`](https://github.com/TanStack/db/commit/945868e95944543ccf5d778409548679a952e249), [`57b5f5d`](https://github.com/TanStack/db/commit/57b5f5de6297326a57ef205a400428af0697b48b)]:
155+
- @tanstack/react-db@0.0.13
156+
- @tanstack/db-collections@0.0.16
157+
158+
## 0.0.17
159+
160+
### Patch Changes
161+
162+
- Updated dependencies [[`5cafaf4`](https://github.com/TanStack/db/commit/5cafaf4f73018599ce799778029833d3fa83dbc9)]:
163+
- @tanstack/db-collections@0.0.15
164+
165+
## 0.0.16
166+
167+
### Patch Changes
168+
169+
- Updated dependencies [[`f6abe9b`](https://github.com/TanStack/db/commit/f6abe9b94b890487fe960bd72a89e4a75de89d46)]:
170+
- @tanstack/db-collections@0.0.14
171+
- @tanstack/react-db@0.0.12
172+
173+
## 0.0.15
174+
175+
### Patch Changes
176+
177+
- Export `ElectricCollectionUtils` & allow passing generic to `createTransaction` ([#179](https://github.com/TanStack/db/pull/179))
178+
179+
- Updated dependencies [[`c5489ff`](https://github.com/TanStack/db/commit/c5489ff276db07a0a4b65876790ccd7f11a6f99d)]:
180+
- @tanstack/db-collections@0.0.13
181+
- @tanstack/react-db@0.0.11
182+
183+
## 0.0.14
184+
185+
### Patch Changes
186+
187+
- Updated dependencies []:
188+
- @tanstack/db-collections@0.0.12
189+
- @tanstack/react-db@0.0.10
190+
191+
## 0.0.13
192+
193+
### Patch Changes
194+
195+
- Updated dependencies []:
196+
- @tanstack/db-collections@0.0.11
197+
- @tanstack/react-db@0.0.9
198+
199+
## 0.0.12
200+
201+
### Patch Changes
202+
203+
- Type PendingMutation whenever possible ([#163](https://github.com/TanStack/db/pull/163))
204+
205+
- Updated dependencies [[`5c538cf`](https://github.com/TanStack/db/commit/5c538cf03573512a8d1bbde96962a9f7ca014708), [`b4602a0`](https://github.com/TanStack/db/commit/b4602a071cb6866bb1338e30d5802220b0d1fc49)]:
206+
- @tanstack/db-collections@0.0.10
207+
- @tanstack/react-db@0.0.8
208+
209+
## 0.0.11
210+
211+
### Patch Changes
212+
213+
- Updated dependencies [[`8b43ad3`](https://github.com/TanStack/db/commit/8b43ad305b277560aed660c31cf1409d22ed1e47)]:
214+
- @tanstack/db-collections@0.0.9
215+
- @tanstack/react-db@0.0.7
216+
217+
## 0.0.10
218+
219+
### Patch Changes
220+
221+
- This change introduces a more streamlined and intuitive API for handling mutations by allowing `onInsert`, `onUpdate`, and `onDelete` handlers to be defined directly on the collection configuration. ([#156](https://github.com/TanStack/db/pull/156))
222+
223+
When `collection.insert()`, `.update()`, or `.delete()` are called outside of an explicit transaction (i.e., not within `useOptimisticMutation`), the library now automatically creates a single-operation transaction and invokes the corresponding handler to persist the change.
224+
225+
Key changes:
226+
227+
- **`@tanstack/db`**: The `Collection` class now supports `onInsert`, `onUpdate`, and `onDelete` in its configuration. Direct calls to mutation methods will throw an error if the corresponding handler is not defined.
228+
- **`@tanstack/db-collections`**:
229+
- `queryCollectionOptions` now accepts the new handlers and will automatically `refetch` the collection's query after a handler successfully completes. This behavior can be disabled if the handler returns `{ refetch: false }`.
230+
- `electricCollectionOptions` also accepts the new handlers. These handlers are now required to return an object with a transaction ID (`{ txid: string }`). The collection then automatically waits for this `txid` to be synced back before resolving the mutation, ensuring consistency.
231+
- **Breaking Change**: Calling `collection.insert()`, `.update()`, or `.delete()` without being inside a `useOptimisticMutation` callback and without a corresponding persistence handler (`onInsert`, etc.) configured on the collection will now throw an error.
232+
233+
This new pattern simplifies the most common use cases, making the code more declarative. The `useOptimisticMutation` hook remains available for more complex scenarios, such as transactions involving multiple mutations across different collections.
234+
235+
***
236+
237+
The documentation and the React Todo example application have been significantly refactored to adopt the new direct persistence handler pattern as the primary way to perform mutations.
238+
239+
- The `README.md` and `docs/overview.md` files have been updated to de-emphasize `useOptimisticMutation` for simple writes. They now showcase the much simpler API of calling `collection.insert()` directly and defining persistence logic in the collection's configuration.
240+
- The React Todo example (`examples/react/todo/src/App.tsx`) has been completely overhauled. All instances of `useOptimisticMutation` have been removed and replaced with the new `onInsert`, `onUpdate`, and `onDelete` handlers, resulting in cleaner and more concise code.
241+
242+
- Updated dependencies [[`80fdac7`](https://github.com/TanStack/db/commit/80fdac76389ea741f5743bc788df375f63fb767b)]:
243+
- @tanstack/db-collections@0.0.8
244+
- @tanstack/react-db@0.0.6
245+
246+
## 0.0.9
247+
248+
### Patch Changes
249+
250+
- Collections must have a getId function & use an id for update/delete operators ([#134](https://github.com/TanStack/db/pull/134))
251+
252+
- Switch to Collection options factories instead of extending the Collection class ([#145](https://github.com/TanStack/db/pull/145))
253+
254+
This refactors `ElectricCollection` and `QueryCollection` into factory functions (`electricCollectionOptions` and `queryCollectionOptions`) that return standard `CollectionConfig` objects and utility functions. Also adds a `createCollection` function to standardize collection instantiation.
255+
256+
- Updated dependencies [[`1fbb844`](https://github.com/TanStack/db/commit/1fbb8447d8425d37cb9ab4f078ffab999b28b06c), [`ee5d026`](https://github.com/TanStack/db/commit/ee5d026715962dd0232fcaca513a8fac9189dce2), [`e4feb0c`](https://github.com/TanStack/db/commit/e4feb0c214835675b47f0aa18a72d004a423df03)]:
257+
- @tanstack/db-collections@0.0.7
258+
- @tanstack/react-db@0.0.5
259+
260+
## 0.0.8
261+
262+
### Patch Changes
263+
264+
- Updated dependencies []:
265+
- @tanstack/db-collections@0.0.6
266+
- @tanstack/react-db@0.0.4
267+
268+
## 0.0.7
269+
270+
### Patch Changes
271+
272+
- Updated dependencies [[`0bbf4c4`](https://github.com/TanStack/db/commit/0bbf4c46e01b382a70a437f05dfc09c9ff749a15)]:
273+
- @tanstack/db-collections@0.0.5
274+
275+
## 0.0.6
276+
277+
### Patch Changes
278+
279+
- Updated dependencies [[`2d0fcf1`](https://github.com/TanStack/db/commit/2d0fcf16a61a3fcd6a7220b5501640cc0f67218f)]:
280+
- @tanstack/db-collections@0.0.4
281+
282+
## 0.0.5
283+
284+
### Patch Changes
285+
286+
- Updated dependencies []:
287+
- @tanstack/db-collections@0.0.3
288+
- @tanstack/react-db@0.0.3
289+
290+
## 0.0.4
291+
292+
### Patch Changes
293+
294+
- Updated dependencies [[`4c82edb`](https://github.com/TanStack/db/commit/4c82edb9547f26c9de44f5bf43d4385c38920672), [`4c82edb`](https://github.com/TanStack/db/commit/4c82edb9547f26c9de44f5bf43d4385c38920672)]:
295+
- @tanstack/react-db@0.0.2
296+
- @tanstack/db-collections@0.0.2
297+
298+
## 0.0.3
299+
300+
### Patch Changes
301+
302+
- Updated dependencies [[`b42479c`](https://github.com/TanStack/db/commit/b42479cf95f9a820b36e01684b13a9179973f3d8)]:
303+
- @tanstack/react-db@0.0.3
304+
305+
## 0.0.2
306+
307+
### Patch Changes
308+
309+
- Updated dependencies [[`9bb6e89`](https://github.com/TanStack/db/commit/9bb6e8909cebdcd7c03091bfc12dd37f5ab2e1ea)]:
310+
- @tanstack/react-db@0.0.2

0 commit comments

Comments
 (0)