@quark-fw/store 0.0.1 → 0.0.2
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.
- package/README.md +37 -0
- package/package.json +7 -3
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @quark-fw/store
|
|
2
|
+
|
|
3
|
+
Isomorphic store and tRPC client hooks for React apps built on the Quark framework. Works during SSR and in the browser.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm i @quark-fw/store
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`react` is a peer dependency.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import Store, { useStore, useTrpc, StoreContext } from "@quark-fw/store";
|
|
17
|
+
|
|
18
|
+
// on the server / app entry: create a Store around your tRPC client and provide it
|
|
19
|
+
const store = new Store({ trpcClient });
|
|
20
|
+
// <StoreContext.Provider value={store}>...</StoreContext.Provider>
|
|
21
|
+
|
|
22
|
+
function TodoList() {
|
|
23
|
+
const trpc = useTrpc(); // typed tRPC client (AppRouter comes from your app)
|
|
24
|
+
const store = useStore(); // shared values/promises, survives SSR serialization
|
|
25
|
+
// ...
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Also exported:
|
|
30
|
+
|
|
31
|
+
- `createTinyRPCClient` — minimal tRPC client factory used by `useTrpc`
|
|
32
|
+
- `jsonSafeFetch` — fetch wrapper that reports JSON errors through the shared error channel
|
|
33
|
+
- `@quark-fw/store/src/errors.js` — `reportError` / `errorMessage` helpers
|
|
34
|
+
- `@quark-fw/store/src/serialize.js` — SSR-safe serialization (`Serialize` type)
|
|
35
|
+
- `@quark-fw/store/src/usePromise.js` — suspense-style promise hook
|
|
36
|
+
|
|
37
|
+
Part of the [Quark framework](https://www.npmjs.com/package/@quark-fw/core).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quark-fw/store",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Isomorphic store and tRPC client hooks for the Quark framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,11 +14,15 @@
|
|
|
14
14
|
"./src/*": "./dist/*",
|
|
15
15
|
"./*": "./dist/*"
|
|
16
16
|
},
|
|
17
|
-
"files": [
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
18
20
|
"scripts": {
|
|
19
21
|
"build": "tsc -p tsconfig.build.json && node ../../scripts/postbuild.mjs"
|
|
20
22
|
},
|
|
21
|
-
"keywords": [
|
|
23
|
+
"keywords": [
|
|
24
|
+
"quark"
|
|
25
|
+
],
|
|
22
26
|
"author": "",
|
|
23
27
|
"license": "ISC",
|
|
24
28
|
"publishConfig": {
|