@blaze-cache/react-query 0.1.0 → 0.2.0-beta

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 +60 -0
  2. package/package.json +4 -2
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/blaze-cache/blaze-cache/main/docs/blaze-cache-logo.png" alt="Blaze Cache logo" width="150">
3
+ </p>
4
+
5
+ <h1 align="center">@blaze-cache/react-query</h1>
6
+
7
+ Persist TanStack Query v5 in WebAssembly — instant first paint after reload while
8
+ stale-while-revalidate still works.
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ npm install @blaze-cache/react-query # @tanstack/react-query ≥ 5 is a peer dependency
14
+ ```
15
+
16
+ ## Quick start
17
+
18
+ ```ts
19
+ // src/queryClient.ts
20
+ import { createBlazeQueryClient } from '@blaze-cache/react-query';
21
+ import { cache } from './blaze.js'; // a cache created by @blaze-cache/core
22
+
23
+ export const queryClient = createBlazeQueryClient({ cache });
24
+ ```
25
+
26
+ ```tsx
27
+ import { useBlazeQuery } from '@blaze-cache/react-query';
28
+
29
+ const todos = useBlazeQuery(cache, {
30
+ queryKey: ['todos'],
31
+ queryFn: () => api.get('/todos').then((response) => response.data),
32
+ });
33
+ ```
34
+
35
+ A mirrored query is injected as `initialData` **with its original `dataUpdatedAt`** —
36
+ the first paint after a reload comes from the cache instantly, while TanStack still
37
+ treats the data as stale and refetches in the background.
38
+
39
+ ## Behaviour
40
+
41
+ * Successful fetches and `setQueryData` are written to the shared cache;
42
+ `removeQueries` deletes from it.
43
+ * Invalidation deliberately keeps the data, so stale-while-revalidate always has
44
+ something to paint.
45
+ * Error states stay in TanStack — only data crosses into the cache.
46
+ * TanStack owns freshness *within* a session; Blaze Cache owns it *across* sessions.
47
+
48
+ ## Documentation
49
+
50
+ Setup and the full integration reference live in the
51
+ [repository README](https://github.com/blaze-cache/blaze-cache#readme).
52
+
53
+ ## Part of Blaze Cache
54
+
55
+ * [`@blaze-cache/core`](https://www.npmjs.com/package/@blaze-cache/core) — the cache itself
56
+ * [`@blaze-cache/axios`](https://www.npmjs.com/package/@blaze-cache/axios) — HTTP adapter
57
+
58
+ ## License
59
+
60
+ [MIT](https://github.com/blaze-cache/blaze-cache/blob/main/LICENSE) © Blaze Cache
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cache/react-query",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-beta",
4
4
  "description": "Persist TanStack Query v5 in WebAssembly — instant first paint after reload while stale-while-revalidate still works",
5
5
  "keywords": [
6
6
  "react-query",
@@ -20,6 +20,7 @@
20
20
  "url": "git+https://github.com/blaze-cache/blaze-cache.git",
21
21
  "directory": "packages/react-query"
22
22
  },
23
+ "homepage": "https://blaze-cache.github.io/docs/",
23
24
  "publishConfig": {
24
25
  "access": "public"
25
26
  },
@@ -37,7 +38,7 @@
37
38
  "dist"
38
39
  ],
39
40
  "dependencies": {
40
- "@blaze-cache/core": "0.1.0"
41
+ "@blaze-cache/core": "0.2.0-beta"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "@tanstack/react-query": "^5.0.0"
@@ -48,6 +49,7 @@
48
49
  },
49
50
  "scripts": {
50
51
  "build": "tsc -p tsconfig.json",
52
+ "test": "pnpm run build && node --test",
51
53
  "typecheck": "tsc -p tsconfig.typecheck.json"
52
54
  }
53
55
  }