@kubb/plugin-swr 5.2.4 → 5.2.5
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/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/docs/overview.md +10 -8
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/docs/overview.md
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
# SWR
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The SWR plugin generates a `useSWR` hook for each query and a `useSWRMutation` hook for each mutation.
|
|
4
4
|
|
|
5
5
|
The plugin ships no HTTP client. Each hook calls a function generated by a client plugin.
|
|
6
6
|
|
|
7
7
|
## Setup
|
|
8
8
|
|
|
9
|
-
- Add `@kubb/plugin-ts` and a client plugin: `@kubb/plugin-fetch` or `@kubb/plugin-axios`.
|
|
10
|
-
- Install
|
|
9
|
+
- Add `@kubb/plugin-ts` and a client plugin: `@kubb/plugin-fetch` or `@kubb/plugin-axios`. Leave `sdk` unset on the client plugin.
|
|
10
|
+
- Install `swr` 2.2 or a later v2 release in the app that uses the generated code.
|
|
11
11
|
- Configure validation on the client plugin, not here.
|
|
12
12
|
|
|
13
13
|
## Options worth knowing
|
|
14
14
|
|
|
15
15
|
- `client` picks `fetch` or `axios` when both client plugins are registered. A single client is detected automatically.
|
|
16
|
-
- `query` and `mutation` set which HTTP methods become queries (`GET`) and mutations (`POST`, `PUT`, `PATCH`, `DELETE`)
|
|
16
|
+
- `query` and `mutation` set which HTTP methods become queries (`GET`) and mutations (`POST`, `PUT`, `PATCH`, `DELETE`). They also set where SWR is imported from (`swr` and `swr/mutation`). Set either to `false` to skip those hooks.
|
|
17
|
+
|
|
18
|
+
The plugin does not generate `useSWRInfinite` hooks.
|
|
19
|
+
|
|
20
|
+
See [Options](https://kubb.dev/extensions/kubb-labs/plugin-swr/options) for every option and its default.
|
|
17
21
|
|
|
18
22
|
## Example
|
|
19
23
|
|
|
24
|
+
The config below generates `useSWR` and `useSWRMutation` hooks that call the Fetch client.
|
|
25
|
+
|
|
20
26
|
```typescript [kubb.config.ts]
|
|
21
27
|
import { defineConfig } from 'kubb/config'
|
|
22
28
|
import { pluginTs } from '@kubb/plugin-ts'
|
|
@@ -33,7 +39,3 @@ export default defineConfig({
|
|
|
33
39
|
],
|
|
34
40
|
})
|
|
35
41
|
```
|
|
36
|
-
|
|
37
|
-
## See also
|
|
38
|
-
|
|
39
|
-
- [SWR](https://swr.vercel.app)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-swr",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.5",
|
|
4
4
|
"description": "Generate type-safe SWR hooks with Kubb. Covers useSWR and useSWRMutation with full TypeScript support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"code-generation",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"registry": "https://registry.npmjs.org/"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@kubb/plugin-ts": "^5.0.
|
|
77
|
+
"@kubb/plugin-ts": "^5.0.10"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@internals/client": "0.0.0",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"kubb": "^5.8.3",
|
|
89
|
-
"swr": "^2.
|
|
89
|
+
"swr": "^2.2.0"
|
|
90
90
|
},
|
|
91
91
|
"peerDependenciesMeta": {
|
|
92
92
|
"swr": {
|