@powersync/tanstack-react-query 0.0.25 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +39 -0
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -158,3 +158,42 @@ export const TodoListDisplay = () => {
158
158
  );
159
159
  };
160
160
  ```
161
+
162
+ ### Drizzle Support
163
+
164
+ [Drizzle queries](https://github.com/powersync-ja/powersync-js/tree/main/packages/drizzle-driver) can be used with the `useQuery` and `useSuspenseQuery` hooks by converting them to a compilable query using the `toCompilableQuery` utility from `@powersync/drizzle-driver`.
165
+
166
+ ```TSX
167
+ // TodoListDisplay.tsx
168
+ import { useQuery } from '@powersync/tanstack-react-query';
169
+ import { toCompilableQuery } from '@powersync/drizzle-driver';
170
+
171
+ export const TodoListDisplay = () => {
172
+ const drizzleQuery = drizzleDb.select().from(lists);
173
+
174
+ const { data: todoLists, isLoading, error } = useQuery({
175
+ queryKey: ['todoLists'],
176
+ query: toCompilableQuery(drizzleQuery), // The type of the rows in `data` are inferred from the Drizzle query
177
+ });
178
+
179
+ if (isLoading) {
180
+ return <div>Loading todo lists...</div>;
181
+ }
182
+
183
+ if (error) {
184
+ return <div>Error loading todo lists: {error.message}</div>;
185
+ }
186
+
187
+ return (
188
+ <ul>
189
+ {todoLists?.map((list) => (
190
+ <li key={list.id}>{list.name}</li>
191
+ ))}
192
+ </ul>
193
+ );
194
+ };
195
+ ```
196
+
197
+ The `toCompilableQuery` function wraps your Drizzle query to make it compatible with useQuery and useSuspenseQuery.
198
+
199
+ For more information on using Drizzle with PowerSync, see the [Drizzle Driver documentation](https://github.com/powersync-ja/powersync-js/tree/main/packages/drizzle-driver).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/tanstack-react-query",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -22,12 +22,12 @@
22
22
  },
23
23
  "homepage": "https://docs.powersync.com",
24
24
  "peerDependencies": {
25
- "@powersync/common": "^1.31.1",
25
+ "@powersync/common": "^1.33.0",
26
26
  "react": "*"
27
27
  },
28
28
  "dependencies": {
29
29
  "@tanstack/react-query": "^5.70.0",
30
- "@powersync/common": "1.31.1",
30
+ "@powersync/common": "1.33.0",
31
31
  "@powersync/react": "1.5.3"
32
32
  },
33
33
  "devDependencies": {