@ahsan-iftikhar-114/api-toolkit-react-query 1.0.0 → 1.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 +364 -723
- package/package.json +37 -16
package/README.md
CHANGED
|
@@ -1,396 +1,277 @@
|
|
|
1
1
|
# @ahsan-iftikhar-114/api-toolkit-react-query
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A reusable API toolkit for React applications using Axios and TanStack Query.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The package provides a generic `createApi()` function for creating API queries and mutations without writing the same API setup repeatedly.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Main Function
|
|
8
8
|
|
|
9
|
-
The
|
|
9
|
+
The main function provided by this package is:
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
When a React application needs information from a backend server, it has to send an **API request**.
|
|
16
|
-
|
|
17
|
-
For example:
|
|
18
|
-
|
|
19
|
-
* Get users
|
|
20
|
-
* Create a user
|
|
21
|
-
* Update a user
|
|
22
|
-
* Delete a user
|
|
23
|
-
* Get products
|
|
24
|
-
* Submit a form
|
|
25
|
-
* Login a user
|
|
26
|
-
* Upload or send data
|
|
27
|
-
* Refresh information from the server
|
|
28
|
-
|
|
29
|
-
Normally, developers have to write a lot of code to manage these requests.
|
|
30
|
-
|
|
31
|
-
This package provides a simpler and more consistent way to manage them.
|
|
32
|
-
|
|
33
|
-
### In simple words
|
|
34
|
-
|
|
35
|
-
You tell the package:
|
|
36
|
-
|
|
37
|
-
**What is this API?**
|
|
38
|
-
|
|
39
|
-
**Which HTTP method should it use?**
|
|
40
|
-
|
|
41
|
-
**Which API URL should it call?**
|
|
42
|
-
|
|
43
|
-
The package handles the rest.
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
# Who is this package for?
|
|
48
|
-
|
|
49
|
-
This package is useful for:
|
|
50
|
-
|
|
51
|
-
* React developers
|
|
52
|
-
* Frontend developers
|
|
53
|
-
* Backend developers working with React
|
|
54
|
-
* Beginners learning API integration
|
|
55
|
-
* Developers building dashboards
|
|
56
|
-
* Developers building admin panels
|
|
57
|
-
* Developers building SaaS applications
|
|
58
|
-
* Developers building business applications
|
|
59
|
-
* Teams that want a consistent API structure
|
|
60
|
-
* Projects using Laravel, Node.js, PHP, .NET, Python or another backend
|
|
61
|
-
|
|
62
|
-
You do not need to understand every internal part of Axios or TanStack Query to use the basic functionality.
|
|
11
|
+
```text
|
|
12
|
+
createApi(name, method, url)
|
|
13
|
+
```
|
|
63
14
|
|
|
64
|
-
|
|
15
|
+
This is the primary function you will use.
|
|
65
16
|
|
|
66
|
-
|
|
17
|
+
The same function can be used for all supported HTTP methods:
|
|
67
18
|
|
|
68
|
-
|
|
19
|
+
```text
|
|
20
|
+
GET
|
|
21
|
+
POST
|
|
22
|
+
PUT
|
|
23
|
+
PATCH
|
|
24
|
+
DELETE
|
|
25
|
+
```
|
|
69
26
|
|
|
70
|
-
|
|
71
|
-
* Axios configuration
|
|
72
|
-
* Authentication tokens
|
|
73
|
-
* Loading states
|
|
74
|
-
* Error states
|
|
75
|
-
* Request cancellation
|
|
76
|
-
* API caching
|
|
77
|
-
* Data refreshing
|
|
78
|
-
* Cache invalidation
|
|
79
|
-
* Query management
|
|
80
|
-
* Mutation management
|
|
27
|
+
The package automatically handles the API as a TanStack Query query or mutation based on the HTTP method.
|
|
81
28
|
|
|
82
|
-
|
|
29
|
+
```text
|
|
30
|
+
GET
|
|
31
|
+
↓
|
|
32
|
+
Query
|
|
83
33
|
|
|
84
|
-
|
|
34
|
+
POST / PUT / PATCH / DELETE
|
|
35
|
+
↓
|
|
36
|
+
Mutation
|
|
37
|
+
```
|
|
85
38
|
|
|
86
|
-
|
|
39
|
+
This provides a consistent way to manage API communication in React applications.
|
|
87
40
|
|
|
88
41
|
---
|
|
89
42
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
The basic idea is very simple.
|
|
43
|
+
## How `createApi()` works
|
|
93
44
|
|
|
94
|
-
|
|
45
|
+
`createApi()` accepts three basic parameters:
|
|
95
46
|
|
|
96
|
-
|
|
47
|
+
| Parameter | Description |
|
|
48
|
+
| --------- | ------------------------- |
|
|
49
|
+
| `name` | A unique name for the API |
|
|
50
|
+
| `method` | HTTP method |
|
|
51
|
+
| `url` | API endpoint |
|
|
97
52
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
**2. Method**
|
|
101
|
-
|
|
102
|
-
The type of request:
|
|
53
|
+
For example:
|
|
103
54
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
* PATCH
|
|
108
|
-
* DELETE
|
|
55
|
+
```text
|
|
56
|
+
createApi("users", "GET", "/users")
|
|
57
|
+
```
|
|
109
58
|
|
|
110
|
-
|
|
59
|
+
This creates a GET API for `/users`.
|
|
111
60
|
|
|
112
|
-
|
|
61
|
+
For creating a user:
|
|
113
62
|
|
|
114
|
-
|
|
63
|
+
```text
|
|
64
|
+
createApi("create-user", "POST", "/users")
|
|
65
|
+
```
|
|
115
66
|
|
|
116
|
-
The
|
|
67
|
+
The function remains the same. Only the API name, method, and URL change.
|
|
117
68
|
|
|
118
69
|
---
|
|
119
70
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
You do not need to be an API expert to understand these.
|
|
123
|
-
|
|
124
|
-
Think about a simple employee management system.
|
|
125
|
-
|
|
126
|
-
### GET
|
|
127
|
-
|
|
128
|
-
Used when you want to **get information**.
|
|
129
|
-
|
|
130
|
-
Examples:
|
|
131
|
-
|
|
132
|
-
* Get employees
|
|
133
|
-
* Get users
|
|
134
|
-
* Get products
|
|
135
|
-
* Get invoices
|
|
71
|
+
## Installation
|
|
136
72
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
### POST
|
|
73
|
+
Install the package using npm:
|
|
140
74
|
|
|
141
|
-
|
|
75
|
+
```bash
|
|
76
|
+
npm install @ahsan-iftikhar-114/api-toolkit-react-query
|
|
77
|
+
```
|
|
142
78
|
|
|
143
|
-
|
|
79
|
+
### Requirements
|
|
144
80
|
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
81
|
+
* React 18 or newer
|
|
82
|
+
* TanStack Query 5 or newer
|
|
83
|
+
* Axios 1 or newer
|
|
84
|
+
* TypeScript 5 or newer recommended
|
|
149
85
|
|
|
150
86
|
---
|
|
151
87
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
Used when you want to **update existing information**.
|
|
88
|
+
## Basic Setup
|
|
155
89
|
|
|
156
|
-
|
|
90
|
+
There are three main steps to start using the package.
|
|
157
91
|
|
|
158
|
-
|
|
159
|
-
* Update user
|
|
160
|
-
* Update profile
|
|
92
|
+
### 1. Configure the API
|
|
161
93
|
|
|
162
|
-
|
|
94
|
+
Configure your backend API URL and, if required, your authentication token.
|
|
163
95
|
|
|
164
|
-
|
|
96
|
+
The configuration is applied globally so that individual API definitions do not need to repeat the same settings.
|
|
165
97
|
|
|
166
|
-
|
|
98
|
+
You can configure:
|
|
167
99
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* Change invoice status
|
|
100
|
+
* Base API URL
|
|
101
|
+
* Request timeout
|
|
102
|
+
* Global headers
|
|
103
|
+
* Authentication token
|
|
173
104
|
|
|
174
105
|
---
|
|
175
106
|
|
|
176
|
-
###
|
|
177
|
-
|
|
178
|
-
Used when you want to **remove something**.
|
|
179
|
-
|
|
180
|
-
Examples:
|
|
181
|
-
|
|
182
|
-
* Delete employee
|
|
183
|
-
* Delete user
|
|
184
|
-
* Delete product
|
|
107
|
+
### 2. Configure TanStack Query
|
|
185
108
|
|
|
186
|
-
|
|
109
|
+
The package uses TanStack Query for managing server data.
|
|
187
110
|
|
|
188
|
-
|
|
111
|
+
Your React application needs a `QueryClient` and `QueryClientProvider`.
|
|
189
112
|
|
|
190
|
-
|
|
113
|
+
You can create a QueryClient using the package helper:
|
|
191
114
|
|
|
192
115
|
```text
|
|
193
|
-
|
|
116
|
+
createApiQueryClient()
|
|
194
117
|
```
|
|
195
118
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
* React
|
|
199
|
-
* Axios
|
|
200
|
-
* TanStack Query
|
|
119
|
+
or use your own TanStack Query `QueryClient`.
|
|
201
120
|
|
|
202
|
-
|
|
121
|
+
The package does not create or force a global QueryClient.
|
|
203
122
|
|
|
204
123
|
---
|
|
205
124
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
You need a React application.
|
|
125
|
+
### 3. Create APIs
|
|
209
126
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
* React 18 or newer
|
|
213
|
-
* TanStack Query 5 or newer
|
|
214
|
-
* Axios 1 or newer
|
|
215
|
-
|
|
216
|
-
TypeScript is recommended, but the package can also be used in JavaScript projects.
|
|
217
|
-
|
|
218
|
-
---
|
|
219
|
-
|
|
220
|
-
# Basic setup
|
|
221
|
-
|
|
222
|
-
The setup can be understood in four simple steps.
|
|
223
|
-
|
|
224
|
-
## Step 1 — Install the package
|
|
225
|
-
|
|
226
|
-
Install the package in your React project.
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
## Step 2 — Tell the package your API address
|
|
231
|
-
|
|
232
|
-
Your backend normally has a common address.
|
|
233
|
-
|
|
234
|
-
For example:
|
|
127
|
+
Create your APIs using:
|
|
235
128
|
|
|
236
129
|
```text
|
|
237
|
-
|
|
130
|
+
createApi(name, method, url)
|
|
238
131
|
```
|
|
239
132
|
|
|
240
|
-
|
|
133
|
+
This is the main API creation function of the package.
|
|
241
134
|
|
|
242
|
-
|
|
135
|
+
---
|
|
243
136
|
|
|
244
|
-
|
|
137
|
+
# HTTP Methods
|
|
245
138
|
|
|
246
|
-
|
|
247
|
-
/users
|
|
248
|
-
/products
|
|
249
|
-
/orders
|
|
250
|
-
/invoices
|
|
251
|
-
```
|
|
139
|
+
## GET
|
|
252
140
|
|
|
253
|
-
|
|
141
|
+
GET requests are used to retrieve data.
|
|
254
142
|
|
|
255
|
-
|
|
143
|
+
Examples:
|
|
256
144
|
|
|
257
|
-
|
|
145
|
+
* Get users
|
|
146
|
+
* Get employees
|
|
147
|
+
* Get products
|
|
148
|
+
* Get orders
|
|
149
|
+
* Get reports
|
|
258
150
|
|
|
259
|
-
|
|
151
|
+
When `GET` is used with `createApi()`, the package creates a TanStack Query.
|
|
260
152
|
|
|
261
|
-
|
|
153
|
+
The query provides access to:
|
|
262
154
|
|
|
263
|
-
|
|
155
|
+
* Response data
|
|
156
|
+
* Loading state
|
|
157
|
+
* Error state
|
|
158
|
+
* Fetching state
|
|
159
|
+
* Refetching
|
|
160
|
+
* Cached data
|
|
264
161
|
|
|
265
162
|
---
|
|
266
163
|
|
|
267
|
-
##
|
|
164
|
+
## POST
|
|
268
165
|
|
|
269
|
-
|
|
166
|
+
POST requests are generally used to create new data.
|
|
270
167
|
|
|
271
|
-
|
|
272
|
-
* Method
|
|
273
|
-
* URL
|
|
274
|
-
|
|
275
|
-
For example, conceptually:
|
|
276
|
-
|
|
277
|
-
**Users**
|
|
168
|
+
Examples:
|
|
278
169
|
|
|
279
|
-
|
|
170
|
+
* Create user
|
|
171
|
+
* Create employee
|
|
172
|
+
* Create product
|
|
173
|
+
* Submit a form
|
|
280
174
|
|
|
281
|
-
|
|
175
|
+
When `POST` is used, the package creates a TanStack Query mutation.
|
|
282
176
|
|
|
283
|
-
|
|
177
|
+
---
|
|
284
178
|
|
|
285
|
-
|
|
179
|
+
## PUT
|
|
286
180
|
|
|
287
|
-
|
|
181
|
+
PUT requests are used to update existing data.
|
|
288
182
|
|
|
289
|
-
|
|
183
|
+
Examples:
|
|
290
184
|
|
|
291
|
-
|
|
185
|
+
* Update user
|
|
186
|
+
* Update employee
|
|
187
|
+
* Update product
|
|
292
188
|
|
|
293
|
-
|
|
189
|
+
PUT APIs are handled as mutations.
|
|
294
190
|
|
|
295
191
|
---
|
|
296
192
|
|
|
297
|
-
|
|
193
|
+
## PATCH
|
|
298
194
|
|
|
299
|
-
|
|
195
|
+
PATCH requests are used to partially update existing data.
|
|
300
196
|
|
|
301
|
-
|
|
197
|
+
Examples:
|
|
302
198
|
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
* Dashboard statistics
|
|
307
|
-
* Notifications
|
|
308
|
-
* User profile
|
|
199
|
+
* Change user status
|
|
200
|
+
* Update employee status
|
|
201
|
+
* Change order status
|
|
309
202
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
* Data
|
|
313
|
-
* Loading state
|
|
314
|
-
* Error state
|
|
315
|
-
* Fetching state
|
|
316
|
-
* Refetching
|
|
317
|
-
* Cached data
|
|
318
|
-
|
|
319
|
-
This means your application can easily know whether information is loading, successfully received, or failed.
|
|
203
|
+
PATCH APIs are handled as mutations.
|
|
320
204
|
|
|
321
205
|
---
|
|
322
206
|
|
|
323
|
-
|
|
207
|
+
## DELETE
|
|
324
208
|
|
|
325
|
-
|
|
209
|
+
DELETE requests are used to remove data.
|
|
326
210
|
|
|
327
|
-
|
|
211
|
+
Examples:
|
|
328
212
|
|
|
329
|
-
*
|
|
330
|
-
* Update employee
|
|
213
|
+
* Delete user
|
|
331
214
|
* Delete employee
|
|
332
|
-
*
|
|
333
|
-
* Update invoice
|
|
334
|
-
* Submit request
|
|
335
|
-
|
|
336
|
-
The package manages these operations as mutations.
|
|
337
|
-
|
|
338
|
-
You can easily know:
|
|
215
|
+
* Delete product
|
|
339
216
|
|
|
340
|
-
|
|
341
|
-
* Whether it succeeded
|
|
342
|
-
* Whether it failed
|
|
343
|
-
* What data was returned
|
|
344
|
-
* What error occurred
|
|
217
|
+
DELETE APIs are handled as mutations.
|
|
345
218
|
|
|
346
219
|
---
|
|
347
220
|
|
|
348
|
-
#
|
|
221
|
+
# Request Data
|
|
349
222
|
|
|
350
|
-
|
|
223
|
+
POST, PUT, PATCH and DELETE requests can send data to the backend.
|
|
351
224
|
|
|
352
|
-
For example,
|
|
225
|
+
For example, an employee API may need:
|
|
353
226
|
|
|
354
227
|
* Name
|
|
355
228
|
* Email
|
|
356
229
|
* Department
|
|
357
230
|
* Position
|
|
358
231
|
|
|
359
|
-
The package
|
|
232
|
+
The package supports request payloads along with query parameters, headers and additional Axios configuration.
|
|
360
233
|
|
|
361
|
-
|
|
234
|
+
---
|
|
362
235
|
|
|
363
|
-
|
|
364
|
-
* Request headers
|
|
365
|
-
* Authentication information
|
|
366
|
-
* Additional Axios configuration
|
|
236
|
+
# Query Parameters
|
|
367
237
|
|
|
368
|
-
|
|
238
|
+
GET requests can include query parameters for:
|
|
369
239
|
|
|
370
|
-
|
|
240
|
+
* Search
|
|
241
|
+
* Pagination
|
|
242
|
+
* Filtering
|
|
243
|
+
* Sorting
|
|
244
|
+
* Page size
|
|
245
|
+
* Status
|
|
371
246
|
|
|
372
|
-
|
|
247
|
+
For example:
|
|
373
248
|
|
|
374
|
-
|
|
249
|
+
```text
|
|
250
|
+
/users?page=1&search=ahsan
|
|
251
|
+
```
|
|
375
252
|
|
|
376
|
-
|
|
253
|
+
Query parameters are also included in the query key, allowing TanStack Query to manage different parameter combinations separately.
|
|
377
254
|
|
|
378
|
-
|
|
255
|
+
---
|
|
379
256
|
|
|
380
|
-
|
|
381
|
-
* A dynamically retrieved token
|
|
257
|
+
# Authentication
|
|
382
258
|
|
|
383
|
-
|
|
259
|
+
The package supports Bearer token authentication.
|
|
384
260
|
|
|
385
|
-
|
|
261
|
+
You can configure either:
|
|
386
262
|
|
|
387
|
-
|
|
263
|
+
* A static token
|
|
264
|
+
* A function that returns the current token
|
|
265
|
+
|
|
266
|
+
This allows applications to keep authentication configuration in one place instead of manually adding the token to every request.
|
|
267
|
+
|
|
268
|
+
The backend remains responsible for authentication and authorization.
|
|
388
269
|
|
|
389
270
|
---
|
|
390
271
|
|
|
391
272
|
# API Base URL
|
|
392
273
|
|
|
393
|
-
|
|
274
|
+
A global base URL can be configured for the application.
|
|
394
275
|
|
|
395
276
|
For example:
|
|
396
277
|
|
|
@@ -398,9 +279,7 @@ For example:
|
|
|
398
279
|
https://api.example.com
|
|
399
280
|
```
|
|
400
281
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
For example:
|
|
282
|
+
Individual APIs can then use relative paths:
|
|
404
283
|
|
|
405
284
|
```text
|
|
406
285
|
/users
|
|
@@ -409,544 +288,302 @@ For example:
|
|
|
409
288
|
/orders
|
|
410
289
|
```
|
|
411
290
|
|
|
412
|
-
This
|
|
413
|
-
|
|
414
|
-
If your backend address changes, you can update the main configuration instead of changing every API.
|
|
291
|
+
This keeps API definitions short and makes it easier to change the backend URL later.
|
|
415
292
|
|
|
416
293
|
---
|
|
417
294
|
|
|
418
|
-
# Loading
|
|
295
|
+
# Loading and Request States
|
|
419
296
|
|
|
420
|
-
|
|
297
|
+
TanStack Query provides request state information for GET requests and mutation state information for POST, PUT, PATCH and DELETE requests.
|
|
421
298
|
|
|
422
|
-
|
|
299
|
+
This can be used to display:
|
|
423
300
|
|
|
424
|
-
* Loading
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
* Deleting...
|
|
301
|
+
* Loading indicators
|
|
302
|
+
* Saving indicators
|
|
303
|
+
* Delete progress
|
|
304
|
+
* Error messages
|
|
305
|
+
* Refreshing states
|
|
430
306
|
|
|
431
|
-
|
|
307
|
+
The package does not require developers to create separate loading state variables for every API request.
|
|
432
308
|
|
|
433
309
|
---
|
|
434
310
|
|
|
435
|
-
# Error
|
|
311
|
+
# Error Handling
|
|
436
312
|
|
|
437
|
-
API
|
|
313
|
+
The package normalizes API errors into a consistent `ApiError` structure.
|
|
438
314
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
* Internet connection problem
|
|
442
|
-
* Server error
|
|
443
|
-
* Unauthorized request
|
|
444
|
-
* Validation error
|
|
445
|
-
* Not found
|
|
446
|
-
* Request timeout
|
|
447
|
-
|
|
448
|
-
The package provides a consistent error format so your application can handle API errors more easily.
|
|
449
|
-
|
|
450
|
-
Instead of every API returning a completely different error structure to your application, the package normalizes common API errors.
|
|
451
|
-
|
|
452
|
-
---
|
|
453
|
-
|
|
454
|
-
# Query parameters
|
|
455
|
-
|
|
456
|
-
Sometimes an API needs additional information in the URL.
|
|
457
|
-
|
|
458
|
-
For example:
|
|
315
|
+
The error can include:
|
|
459
316
|
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
*
|
|
465
|
-
*
|
|
317
|
+
* Message
|
|
318
|
+
* HTTP status
|
|
319
|
+
* Status text
|
|
320
|
+
* Response data
|
|
321
|
+
* Validation errors
|
|
322
|
+
* Original Axios error
|
|
466
323
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
This makes it suitable for:
|
|
470
|
-
|
|
471
|
-
* Search pages
|
|
472
|
-
* Data tables
|
|
473
|
-
* Pagination
|
|
474
|
-
* Filters
|
|
475
|
-
* Reports
|
|
476
|
-
* Admin dashboards
|
|
324
|
+
This provides a consistent way to handle API errors throughout the application.
|
|
477
325
|
|
|
478
326
|
---
|
|
479
327
|
|
|
480
328
|
# Caching
|
|
481
329
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
Caching means your application can temporarily remember information it has already received.
|
|
485
|
-
|
|
486
|
-
This can reduce unnecessary API requests.
|
|
487
|
-
|
|
488
|
-
For example:
|
|
489
|
-
|
|
490
|
-
A user opens the employee page.
|
|
330
|
+
GET requests use TanStack Query's caching system.
|
|
491
331
|
|
|
492
|
-
|
|
332
|
+
Previously fetched data can be stored in the query cache according to the configured TanStack Query settings.
|
|
493
333
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
This can make applications feel faster and reduce unnecessary network requests.
|
|
334
|
+
Caching can reduce unnecessary API requests and improve the responsiveness of an application.
|
|
497
335
|
|
|
498
336
|
---
|
|
499
337
|
|
|
500
338
|
# Refetching
|
|
501
339
|
|
|
502
|
-
|
|
340
|
+
TanStack Query provides refetching functionality for keeping server data up to date.
|
|
503
341
|
|
|
504
|
-
|
|
342
|
+
Depending on your configuration, queries can be refetched when:
|
|
505
343
|
|
|
506
|
-
*
|
|
507
|
-
* User returns to a page
|
|
508
|
-
* Application reconnects to the internet
|
|
344
|
+
* A user manually refreshes data
|
|
509
345
|
* Data becomes stale
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
This allows your application to keep server data up to date.
|
|
346
|
+
* The application reconnects
|
|
347
|
+
* A component mounts
|
|
348
|
+
* A configured interval is reached
|
|
514
349
|
|
|
515
350
|
---
|
|
516
351
|
|
|
517
|
-
# Cache
|
|
518
|
-
|
|
519
|
-
Suppose you have an employee list.
|
|
520
|
-
|
|
521
|
-
A user creates a new employee.
|
|
352
|
+
# Cache Invalidation
|
|
522
353
|
|
|
523
|
-
|
|
354
|
+
When data is created, updated or deleted, previously cached data may become outdated.
|
|
524
355
|
|
|
525
|
-
The package provides cache
|
|
356
|
+
The package provides cache utilities for invalidating queries.
|
|
526
357
|
|
|
527
|
-
|
|
358
|
+
Available utilities include:
|
|
528
359
|
|
|
529
|
-
|
|
360
|
+
```text
|
|
361
|
+
invalidateApi()
|
|
362
|
+
invalidateApis()
|
|
363
|
+
invalidateAllApis()
|
|
364
|
+
```
|
|
530
365
|
|
|
531
|
-
|
|
532
|
-
* Updating records
|
|
533
|
-
* Deleting records
|
|
534
|
-
* Changing statuses
|
|
535
|
-
* Performing other server-side operations
|
|
366
|
+
You can use these after mutations to tell TanStack Query that related data should be refreshed.
|
|
536
367
|
|
|
537
368
|
---
|
|
538
369
|
|
|
539
|
-
# Request
|
|
540
|
-
|
|
541
|
-
Sometimes a request is no longer needed.
|
|
542
|
-
|
|
543
|
-
For example:
|
|
544
|
-
|
|
545
|
-
A user starts searching for employees.
|
|
546
|
-
|
|
547
|
-
Then immediately changes the search.
|
|
548
|
-
|
|
549
|
-
The previous request may no longer be useful.
|
|
370
|
+
# Request Cancellation
|
|
550
371
|
|
|
551
372
|
The package supports request cancellation through `AbortSignal`.
|
|
552
373
|
|
|
553
|
-
This
|
|
554
|
-
|
|
555
|
-
---
|
|
556
|
-
|
|
557
|
-
# Advanced configuration
|
|
558
|
-
|
|
559
|
-
Although the basic API is simple, the package also supports advanced configuration.
|
|
560
|
-
|
|
561
|
-
Developers can use TanStack Query options such as:
|
|
562
|
-
|
|
563
|
-
* Cache duration
|
|
564
|
-
* Stale time
|
|
565
|
-
* Retry behavior
|
|
566
|
-
* Automatic refetching
|
|
567
|
-
* Conditional requests
|
|
568
|
-
* Placeholder data
|
|
569
|
-
* Initial data
|
|
570
|
-
* Data selection
|
|
571
|
-
* Other compatible TanStack Query options
|
|
572
|
-
|
|
573
|
-
This means beginners can start with the simple functionality while experienced developers can customize the behavior when needed.
|
|
574
|
-
|
|
575
|
-
---
|
|
576
|
-
|
|
577
|
-
# TypeScript support
|
|
578
|
-
|
|
579
|
-
The package is designed with TypeScript support in mind.
|
|
580
|
-
|
|
581
|
-
You can define the type of:
|
|
582
|
-
|
|
583
|
-
* API response
|
|
584
|
-
* Request data
|
|
585
|
-
* Mutation context
|
|
586
|
-
* Selected data
|
|
587
|
-
|
|
588
|
-
This helps developers get:
|
|
589
|
-
|
|
590
|
-
* Better autocomplete
|
|
591
|
-
* Better editor support
|
|
592
|
-
* Better type checking
|
|
593
|
-
* Fewer mistakes
|
|
594
|
-
* Easier maintenance
|
|
595
|
-
|
|
596
|
-
TypeScript is especially useful for large applications.
|
|
597
|
-
|
|
598
|
-
---
|
|
599
|
-
|
|
600
|
-
# Works with different backends
|
|
601
|
-
|
|
602
|
-
This package is designed for the frontend API layer.
|
|
603
|
-
|
|
604
|
-
Your backend can be built using many different technologies.
|
|
605
|
-
|
|
606
|
-
For example:
|
|
607
|
-
|
|
608
|
-
* Laravel
|
|
609
|
-
* PHP
|
|
610
|
-
* Node.js
|
|
611
|
-
* Express
|
|
612
|
-
* NestJS
|
|
613
|
-
* .NET
|
|
614
|
-
* ASP.NET
|
|
615
|
-
* Django
|
|
616
|
-
* FastAPI
|
|
617
|
-
* Spring Boot
|
|
618
|
-
* Other REST APIs
|
|
619
|
-
|
|
620
|
-
As long as your backend provides an API that your React application can communicate with, this package can be used as the API management layer.
|
|
621
|
-
|
|
622
|
-
---
|
|
623
|
-
|
|
624
|
-
# What happens behind the scenes?
|
|
625
|
-
|
|
626
|
-
You do not need to manage all of these individually.
|
|
627
|
-
|
|
628
|
-
The package combines:
|
|
629
|
-
|
|
630
|
-
**React**
|
|
631
|
-
|
|
632
|
-
↓
|
|
633
|
-
|
|
634
|
-
**API Toolkit**
|
|
635
|
-
|
|
636
|
-
↓
|
|
637
|
-
|
|
638
|
-
**Axios**
|
|
639
|
-
|
|
640
|
-
↓
|
|
641
|
-
|
|
642
|
-
**Backend API**
|
|
643
|
-
|
|
644
|
-
And for server data management:
|
|
645
|
-
|
|
646
|
-
**TanStack Query**
|
|
647
|
-
|
|
648
|
-
↓
|
|
649
|
-
|
|
650
|
-
**Caching**
|
|
651
|
-
|
|
652
|
-
↓
|
|
653
|
-
|
|
654
|
-
**Refetching**
|
|
655
|
-
|
|
656
|
-
↓
|
|
374
|
+
This is useful when a request is no longer required, such as when a user changes a search request before the previous request has completed.
|
|
657
375
|
|
|
658
|
-
|
|
376
|
+
The package also provides:
|
|
659
377
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
378
|
+
```text
|
|
379
|
+
cancelApi()
|
|
380
|
+
```
|
|
663
381
|
|
|
664
|
-
|
|
382
|
+
for cancelling queries associated with an API.
|
|
665
383
|
|
|
666
384
|
---
|
|
667
385
|
|
|
668
|
-
#
|
|
386
|
+
# React Query Options
|
|
669
387
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
Define an API using:
|
|
673
|
-
|
|
674
|
-
* Name
|
|
675
|
-
* Method
|
|
676
|
-
* URL
|
|
388
|
+
The package supports standard TanStack Query options.
|
|
677
389
|
|
|
678
|
-
|
|
390
|
+
These include:
|
|
679
391
|
|
|
680
|
-
|
|
392
|
+
* `staleTime`
|
|
393
|
+
* `gcTime`
|
|
394
|
+
* `enabled`
|
|
395
|
+
* `retry`
|
|
396
|
+
* `retryDelay`
|
|
397
|
+
* `refetchInterval`
|
|
398
|
+
* `refetchOnWindowFocus`
|
|
399
|
+
* `refetchOnReconnect`
|
|
400
|
+
* `refetchOnMount`
|
|
401
|
+
* `initialData`
|
|
402
|
+
* `placeholderData`
|
|
403
|
+
* `select`
|
|
681
404
|
|
|
682
|
-
|
|
405
|
+
This allows the basic API creation system to remain simple while still providing access to TanStack Query's configuration options.
|
|
683
406
|
|
|
684
407
|
---
|
|
685
408
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
Configure:
|
|
689
|
-
|
|
690
|
-
* API URL
|
|
691
|
-
* Timeout
|
|
692
|
-
* Headers
|
|
693
|
-
* Authentication
|
|
409
|
+
# Data Selection
|
|
694
410
|
|
|
695
|
-
|
|
411
|
+
The `select` option can be used when the component only needs a specific part or transformed version of the API response.
|
|
696
412
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
### Built-in React Query support
|
|
413
|
+
For example, an API may return a complete list of users while a component only needs the number of users.
|
|
700
414
|
|
|
701
|
-
|
|
415
|
+
TanStack Query's `select` functionality can be used for this transformation without changing the original cached data.
|
|
702
416
|
|
|
703
417
|
---
|
|
704
418
|
|
|
705
|
-
|
|
419
|
+
# Axios Configuration
|
|
706
420
|
|
|
707
|
-
|
|
421
|
+
The package uses Axios for HTTP requests.
|
|
708
422
|
|
|
709
|
-
|
|
423
|
+
In addition to the global configuration, individual requests can use:
|
|
710
424
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
### Caching support
|
|
425
|
+
* Request-specific headers
|
|
426
|
+
* Query parameters
|
|
427
|
+
* Request data
|
|
428
|
+
* Axios request configuration
|
|
429
|
+
* Request cancellation
|
|
718
430
|
|
|
719
|
-
|
|
431
|
+
This provides additional control when a specific API needs different settings.
|
|
720
432
|
|
|
721
433
|
---
|
|
722
434
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
Cancel requests when they are no longer required.
|
|
435
|
+
# TypeScript
|
|
726
436
|
|
|
727
|
-
|
|
437
|
+
The package supports TypeScript generics for API responses, request data and selected data.
|
|
728
438
|
|
|
729
|
-
|
|
439
|
+
This provides type checking and editor support when working with API data.
|
|
730
440
|
|
|
731
|
-
|
|
441
|
+
TypeScript is recommended for larger React applications.
|
|
732
442
|
|
|
733
443
|
---
|
|
734
444
|
|
|
735
|
-
|
|
445
|
+
# Query Client
|
|
736
446
|
|
|
737
|
-
|
|
447
|
+
The package provides:
|
|
738
448
|
|
|
739
|
-
|
|
449
|
+
```text
|
|
450
|
+
createApiQueryClient()
|
|
451
|
+
```
|
|
740
452
|
|
|
741
|
-
|
|
453
|
+
as a helper for creating a TanStack Query `QueryClient`.
|
|
742
454
|
|
|
743
|
-
|
|
455
|
+
You can also create and configure your own `QueryClient`.
|
|
744
456
|
|
|
745
|
-
|
|
746
|
-
* HRMS systems
|
|
747
|
-
* CRM systems
|
|
748
|
-
* ERP systems
|
|
749
|
-
* SaaS applications
|
|
750
|
-
* E-commerce applications
|
|
751
|
-
* Project management applications
|
|
752
|
-
* Business management systems
|
|
753
|
-
* Dashboards
|
|
754
|
-
* Customer portals
|
|
755
|
-
* Employee portals
|
|
756
|
-
* Internal company applications
|
|
757
|
-
* REST API based React applications
|
|
457
|
+
The package does not maintain a hidden global QueryClient. This allows the application to control its own QueryClient and cache lifecycle.
|
|
758
458
|
|
|
759
459
|
---
|
|
760
460
|
|
|
761
|
-
#
|
|
461
|
+
# Complete API Flow
|
|
762
462
|
|
|
763
|
-
The package
|
|
463
|
+
The package follows this general flow:
|
|
764
464
|
|
|
765
465
|
```text
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
466
|
+
createApi(name, method, url)
|
|
467
|
+
|
|
|
468
|
+
v
|
|
469
|
+
API Definition
|
|
470
|
+
|
|
|
471
|
+
v
|
|
472
|
+
Axios
|
|
473
|
+
|
|
|
474
|
+
v
|
|
475
|
+
Backend API
|
|
476
|
+
|
|
|
477
|
+
v
|
|
478
|
+
TanStack Query
|
|
479
|
+
|
|
|
480
|
+
v
|
|
481
|
+
Data / Cache / Loading
|
|
482
|
+
Errors / Refetching
|
|
483
|
+
Mutations / Invalidation
|
|
775
484
|
```
|
|
776
485
|
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
---
|
|
780
|
-
|
|
781
|
-
# Supported HTTP Methods
|
|
782
|
-
|
|
783
|
-
The package supports:
|
|
784
|
-
|
|
785
|
-
| Method | Purpose |
|
|
786
|
-
| ------ | ---------------------------- |
|
|
787
|
-
| GET | Get information |
|
|
788
|
-
| POST | Create information |
|
|
789
|
-
| PUT | Update information |
|
|
790
|
-
| PATCH | Partially update information |
|
|
791
|
-
| DELETE | Delete information |
|
|
486
|
+
The developer mainly works with `createApi()` while Axios and TanStack Query handle the underlying API and server-state functionality.
|
|
792
487
|
|
|
793
488
|
---
|
|
794
489
|
|
|
795
|
-
#
|
|
796
|
-
|
|
797
|
-
### API
|
|
798
|
-
|
|
799
|
-
An API allows your application to communicate with a backend server.
|
|
800
|
-
|
|
801
|
-
### Axios
|
|
490
|
+
# Example Use Cases
|
|
802
491
|
|
|
803
|
-
|
|
492
|
+
The same generic API function can be used in different types of applications.
|
|
804
493
|
|
|
805
|
-
|
|
494
|
+
For an HRMS:
|
|
806
495
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
* Server state
|
|
817
|
-
|
|
818
|
-
### Query
|
|
819
|
-
|
|
820
|
-
A query normally means:
|
|
821
|
-
|
|
822
|
-
**"Get information from the server."**
|
|
823
|
-
|
|
824
|
-
### Mutation
|
|
825
|
-
|
|
826
|
-
A mutation normally means:
|
|
827
|
-
|
|
828
|
-
**"Change something on the server."**
|
|
829
|
-
|
|
830
|
-
### Cache
|
|
496
|
+
```text
|
|
497
|
+
Employees
|
|
498
|
+
Attendance
|
|
499
|
+
Leave
|
|
500
|
+
Payroll
|
|
501
|
+
Performance
|
|
502
|
+
Requests
|
|
503
|
+
Notifications
|
|
504
|
+
```
|
|
831
505
|
|
|
832
|
-
|
|
506
|
+
For a CRM:
|
|
833
507
|
|
|
834
|
-
|
|
508
|
+
```text
|
|
509
|
+
Leads
|
|
510
|
+
Contacts
|
|
511
|
+
Companies
|
|
512
|
+
Opportunities
|
|
513
|
+
Deals
|
|
514
|
+
Customers
|
|
515
|
+
```
|
|
835
516
|
|
|
836
|
-
|
|
517
|
+
For an e-commerce application:
|
|
837
518
|
|
|
838
|
-
|
|
519
|
+
```text
|
|
520
|
+
Products
|
|
521
|
+
Categories
|
|
522
|
+
Orders
|
|
523
|
+
Customers
|
|
524
|
+
Payments
|
|
525
|
+
```
|
|
839
526
|
|
|
840
|
-
|
|
527
|
+
The API creation pattern remains the same.
|
|
841
528
|
|
|
842
529
|
---
|
|
843
530
|
|
|
844
|
-
#
|
|
845
|
-
|
|
846
|
-
No.
|
|
847
|
-
|
|
848
|
-
The package is designed around a simple API creation concept.
|
|
849
|
-
|
|
850
|
-
You mainly need to understand three things:
|
|
851
|
-
|
|
852
|
-
**Name → Method → URL**
|
|
853
|
-
|
|
854
|
-
For example:
|
|
855
|
-
|
|
856
|
-
**Employees → GET → /employees**
|
|
531
|
+
# Supported Methods
|
|
857
532
|
|
|
858
|
-
|
|
533
|
+
| Method | Type | Purpose |
|
|
534
|
+
| ------ | -------- | --------------------- |
|
|
535
|
+
| GET | Query | Retrieve data |
|
|
536
|
+
| POST | Mutation | Create data |
|
|
537
|
+
| PUT | Mutation | Update data |
|
|
538
|
+
| PATCH | Mutation | Partially update data |
|
|
539
|
+
| DELETE | Mutation | Delete data |
|
|
859
540
|
|
|
860
541
|
---
|
|
861
542
|
|
|
862
|
-
#
|
|
543
|
+
# Backend Compatibility
|
|
863
544
|
|
|
864
|
-
|
|
545
|
+
The package can be used with any backend that provides a compatible HTTP API.
|
|
865
546
|
|
|
866
|
-
|
|
547
|
+
Examples include:
|
|
867
548
|
|
|
868
|
-
*
|
|
869
|
-
*
|
|
870
|
-
*
|
|
871
|
-
*
|
|
872
|
-
*
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
This gives your application a consistent API architecture instead of creating a different API implementation for every module.
|
|
880
|
-
|
|
881
|
-
---
|
|
882
|
-
|
|
883
|
-
# Browser Support
|
|
884
|
-
|
|
885
|
-
This package is intended for modern React applications running in environments that support:
|
|
886
|
-
|
|
887
|
-
* Promises
|
|
888
|
-
* Fetch-compatible AbortSignal
|
|
889
|
-
* Modern JavaScript features
|
|
549
|
+
* Laravel
|
|
550
|
+
* PHP
|
|
551
|
+
* Node.js
|
|
552
|
+
* Express
|
|
553
|
+
* NestJS
|
|
554
|
+
* .NET
|
|
555
|
+
* ASP.NET
|
|
556
|
+
* Django
|
|
557
|
+
* FastAPI
|
|
558
|
+
* Spring Boot
|
|
559
|
+
* Other REST API backends
|
|
890
560
|
|
|
891
|
-
|
|
561
|
+
The package is responsible for the React API layer. Backend authentication, authorization, validation and business logic remain the responsibility of the backend application.
|
|
892
562
|
|
|
893
563
|
---
|
|
894
564
|
|
|
895
|
-
# Security
|
|
565
|
+
# Security
|
|
896
566
|
|
|
897
|
-
|
|
567
|
+
The package supports authentication tokens but does not provide an authentication system.
|
|
898
568
|
|
|
899
|
-
Your application and backend are
|
|
569
|
+
Your application and backend are responsible for:
|
|
900
570
|
|
|
901
571
|
* Login
|
|
902
|
-
*
|
|
572
|
+
* Registration
|
|
903
573
|
* Token generation
|
|
904
|
-
* Token expiration
|
|
905
574
|
* Token refresh
|
|
906
|
-
*
|
|
575
|
+
* Token expiration
|
|
907
576
|
* Roles
|
|
908
|
-
*
|
|
909
|
-
*
|
|
910
|
-
|
|
911
|
-
Never expose sensitive secrets such as backend private keys or server credentials in a React frontend.
|
|
912
|
-
|
|
913
|
-
---
|
|
914
|
-
|
|
915
|
-
# Performance
|
|
916
|
-
|
|
917
|
-
The package uses TanStack Query for server-state management and caching.
|
|
918
|
-
|
|
919
|
-
Performance will depend on:
|
|
920
|
-
|
|
921
|
-
* API design
|
|
922
|
-
* Backend performance
|
|
923
|
-
* Database performance
|
|
924
|
-
* Network speed
|
|
925
|
-
* Query configuration
|
|
926
|
-
* Cache configuration
|
|
927
|
-
* Amount of requested data
|
|
928
|
-
|
|
929
|
-
For large applications, developers should also use appropriate backend pagination, filtering, indexing and optimized API responses.
|
|
930
|
-
|
|
931
|
-
---
|
|
932
|
-
|
|
933
|
-
# Package Philosophy
|
|
934
|
-
|
|
935
|
-
The main goal of this package is:
|
|
936
|
-
|
|
937
|
-
> **Make API integration simple, reusable and consistent.**
|
|
938
|
-
|
|
939
|
-
Instead of creating a separate API architecture for every React project, developers can use the same basic approach across different applications.
|
|
940
|
-
|
|
941
|
-
Beginners can start with the simple functionality.
|
|
577
|
+
* Permissions
|
|
578
|
+
* Authorization
|
|
942
579
|
|
|
943
|
-
|
|
580
|
+
Do not expose private server credentials or secrets in a React application.
|
|
944
581
|
|
|
945
582
|
---
|
|
946
583
|
|
|
947
584
|
# Technology
|
|
948
585
|
|
|
949
|
-
This package
|
|
586
|
+
This package uses:
|
|
950
587
|
|
|
951
588
|
* React
|
|
952
589
|
* TypeScript
|
|
@@ -955,63 +592,67 @@ This package is built around:
|
|
|
955
592
|
|
|
956
593
|
---
|
|
957
594
|
|
|
958
|
-
#
|
|
595
|
+
# Package Structure
|
|
959
596
|
|
|
960
|
-
|
|
597
|
+
The package separates its main responsibilities into:
|
|
961
598
|
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
* Axios TypeScript
|
|
978
|
-
* TanStack Query TypeScript
|
|
979
|
-
* React API management
|
|
980
|
-
* Generic React API client
|
|
981
|
-
* Reusable React API hooks
|
|
982
|
-
* API request management
|
|
983
|
-
* React server state management
|
|
599
|
+
```text
|
|
600
|
+
Configuration
|
|
601
|
+
|
|
|
602
|
+
v
|
|
603
|
+
Axios
|
|
604
|
+
|
|
|
605
|
+
v
|
|
606
|
+
API Request
|
|
607
|
+
|
|
|
608
|
+
v
|
|
609
|
+
TanStack Query
|
|
610
|
+
|
|
|
611
|
+
v
|
|
612
|
+
React Application
|
|
613
|
+
```
|
|
984
614
|
|
|
985
|
-
|
|
615
|
+
This keeps API communication and server-state management reusable across the application.
|
|
986
616
|
|
|
987
|
-
|
|
617
|
+
---
|
|
988
618
|
|
|
989
|
-
|
|
619
|
+
# Main API
|
|
990
620
|
|
|
991
|
-
|
|
621
|
+
The main public function is:
|
|
992
622
|
|
|
993
|
-
|
|
623
|
+
```text
|
|
624
|
+
createApi(name, method, url)
|
|
625
|
+
```
|
|
994
626
|
|
|
995
|
-
|
|
627
|
+
Additional public utilities include:
|
|
996
628
|
|
|
997
|
-
|
|
629
|
+
```text
|
|
630
|
+
configureApi()
|
|
631
|
+
createApiQueryClient()
|
|
632
|
+
invalidateApi()
|
|
633
|
+
invalidateApis()
|
|
634
|
+
invalidateAllApis()
|
|
635
|
+
cancelApi()
|
|
636
|
+
```
|
|
998
637
|
|
|
999
|
-
|
|
638
|
+
The package also provides TypeScript types for API configuration, requests, responses, errors and React Query options.
|
|
1000
639
|
|
|
1001
640
|
---
|
|
1002
641
|
|
|
1003
|
-
#
|
|
642
|
+
# Keywords
|
|
1004
643
|
|
|
1005
|
-
|
|
644
|
+
React API toolkit, React API client, React Query API, TanStack Query API, Axios React Query, Axios API client, React API hooks, React Query hooks, React mutation hooks, TypeScript API client, React REST API client, API caching, React Query caching, API cache invalidation, Axios TypeScript, TanStack Query TypeScript, React API management, generic React API client, reusable React API hooks, API request management, React server state management.
|
|
1006
645
|
|
|
1007
646
|
---
|
|
1008
647
|
|
|
1009
|
-
#
|
|
648
|
+
# License
|
|
1010
649
|
|
|
1011
|
-
|
|
650
|
+
This package is released under the MIT License.
|
|
1012
651
|
|
|
1013
|
-
|
|
652
|
+
See the `LICENSE` file for complete license information.
|
|
1014
653
|
|
|
1015
|
-
|
|
654
|
+
---
|
|
655
|
+
|
|
656
|
+
# Author
|
|
1016
657
|
|
|
1017
|
-
|
|
658
|
+
Ahsan Iftikhar
|