@@ -18,6 +18,32 @@ yarn add react-query-key-manager
18
18
npm install react-query-key-manager
19
19
```
20
20
21
+ ## 🔑 New ` defineKey ` Helper (v0.0.113)
22
+
23
+ A new ` defineKey ` helper is available to make query key definitions more expressive and type-safe.
24
+ It’s fully ** optional** and works alongside existing patterns — you can adopt it gradually.
25
+
26
+ ### Example
27
+
28
+ ``` ts
29
+ import { QueryKeyManager , defineKey } from " react-query-key-manager" ;
30
+
31
+ const userKeys = QueryKeyManager .create (" user" , {
32
+ profile: defineKey ((userId : string ) => [" user" , " profile" , userId ]),
33
+ settings: defineKey ((userId : string , section ? : string ) => [
34
+ " user" ,
35
+ " settings" ,
36
+ userId ,
37
+ section ,
38
+ ]),
39
+ list: defineKey (() => [" user" , " list" ]),
40
+ });
41
+
42
+ // ✅ Strongly typed inference:
43
+ const p = userKeys .profile (" 123" );
44
+ // type: readonly ["user", "profile", string]
45
+ ```
46
+
21
47
## 🎯 Problem Statement
22
48
23
49
When working on medium-to-large projects with React Query, query keys quickly become a mess:
0 commit comments