@pixel-pulse/cache-brain-react 1.0.0 → 1.0.1
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 +9 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img src="https://cache-brain.netlify.app/og-image-next.
|
|
2
|
+
<img src="https://cache-brain.netlify.app/og-image-next.png" width="100%" alt="Cache Brain - Smart Caching Engine"/>
|
|
3
3
|
|
|
4
4
|
<br/>
|
|
5
5
|
|
|
@@ -47,6 +47,7 @@ npm add @pixel-pulse/cache-brain-react
|
|
|
47
47
|
## 🚀 Setup
|
|
48
48
|
|
|
49
49
|
#### Wrap your App
|
|
50
|
+
|
|
50
51
|
In **Next.js (App Router)**, wrap your `layout.tsx`. In Vite, wrap your `App.tsx`.
|
|
51
52
|
|
|
52
53
|
```TypeScript
|
|
@@ -79,7 +80,7 @@ import { useSmartCache } from "@pixel-pulse/cache-brain-react";
|
|
|
79
80
|
|
|
80
81
|
function UserProfile({ id }) {
|
|
81
82
|
const { data, isLoading, error, revalidate } = useSmartCache(
|
|
82
|
-
['user', id],
|
|
83
|
+
['user', id],
|
|
83
84
|
() => fetch(`/api/user/${id}`).then(res => res.json())
|
|
84
85
|
);
|
|
85
86
|
|
|
@@ -99,12 +100,12 @@ function UserProfile({ id }) {
|
|
|
99
100
|
|
|
100
101
|
The `useSmartCache` hook accepts a configuration object as its third argument to fine-tune the behavior of individual requests.
|
|
101
102
|
|
|
102
|
-
| Property | Type | Description | Default
|
|
103
|
-
| :--------- | :--------- | :--------------------------------------------------------------------------------------------------- |
|
|
104
|
-
| `strategy` | `Strategy` | Defines how the engine handles data (e.g., `swr`, `network-first`). | `default`
|
|
105
|
-
| `ttl` | `number` | Time-to-live in milliseconds. Overrides the global client setting for this fetch. | `300000`
|
|
106
|
-
| `dedupe` | `boolean` | When `true`, multiple identical calls within the same timeframe are collapsed into a single request. | `true`
|
|
107
|
-
| `persist` | `boolean` | If enabled, the engine will attempt to save this specific result to persistent storage. | `false`
|
|
103
|
+
| Property | Type | Description | Default |
|
|
104
|
+
| :--------- | :--------- | :--------------------------------------------------------------------------------------------------- | :-------- |
|
|
105
|
+
| `strategy` | `Strategy` | Defines how the engine handles data (e.g., `swr`, `network-first`). | `default` |
|
|
106
|
+
| `ttl` | `number` | Time-to-live in milliseconds. Overrides the global client setting for this fetch. | `300000` |
|
|
107
|
+
| `dedupe` | `boolean` | When `true`, multiple identical calls within the same timeframe are collapsed into a single request. | `true` |
|
|
108
|
+
| `persist` | `boolean` | If enabled, the engine will attempt to save this specific result to persistent storage. | `false` |
|
|
108
109
|
|
|
109
110
|
---
|
|
110
111
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixel-pulse/cache-brain-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "React & Next.js adapter for Cache Brain engine.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@pixel-pulse/cache-brain": "1.0.
|
|
19
|
+
"@pixel-pulse/cache-brain": "1.0.1"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"react": ">=18.0.0",
|