Skip to content

Commit 82533ea

Browse files
authored
Merge pull request reduxjs#1180 from Shrugsy/docs/add-rtkq-to-readme
📝 Add RTKQ section to README
2 parents af7c804 + 2c80a48 commit 82533ea

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ The **Redux Toolkit** package is intended to be the standard way to write Redux
5050

5151
We can't solve every use case, but in the spirit of [`create-react-app`](https://github.com/facebook/create-react-app) and [`apollo-boost`](https://www.apollographql.com/blog/announcement/frontend/zero-config-graphql-state-management/), we can try to provide some tools that abstract over the setup process and handle the most common use cases, as well as include some useful utilities that will let the user simplify their application code.
5252

53-
Because of that, this package is deliberately limited in scope. It does _not_ address concepts like "reusable encapsulated Redux modules", data caching, folder or file structures, managing entity relationships in the store, and so on.
53+
Because of that, this package is deliberately limited in scope. It does _not_ address concepts like "reusable encapsulated Redux modules", folder or file structures, managing entity relationships in the store, and so on.
54+
55+
Redux Toolkit also includes a powerful data fetching and caching capability that we've dubbed "RTK Query". It's included in the package as a separate set of entry points. It's optional, but can eliminate the need to hand-write data fetching logic yourself.
5456

5557
## What's Included
5658

@@ -64,6 +66,33 @@ Redux Toolkit includes these APIs:
6466
- `createEntityAdapter`: generates a set of reusable reducers and selectors to manage normalized data in the store
6567
- The `createSelector` utility from the [Reselect](https://github.com/reduxjs/reselect) library, re-exported for ease of use.
6668

69+
## RTK Query
70+
71+
**RTK Query** is provided as an optional addon within the `@reduxjs/toolkit` package. It is purpose-built to solve the use case of data fetching and caching, supplying a compact, but powerful toolset to define an API interface layer for your app. It is intended to simplify common cases for loading data in a web application, eliminating the need to hand-write data fetching & caching logic yourself.
72+
73+
RTK Query is built on top of the Redux Toolkit core for its implementation, using [Redux](https://redux.js.org/) internally for its architecture. Although knowledge of Redux and RTK are not required to use RTK Query, you should explore all of the additional global store management capabilities they provide, as well as installing the [Redux DevTools browser extension](https://github.com/reduxjs/redux-devtools), which works flawlessly with RTK Query to traverse and replay a timeline of your request & cache behavior.
74+
75+
RTK Query is included within the installation of the core Redux Toolkit package. It is available via either of the two entry points below:
76+
77+
```ts no-transpile
78+
import { createApi } from '@reduxjs/toolkit/query'
79+
80+
/* React-specific entry point that automatically generates
81+
hooks corresponding to the defined endpoints */
82+
import { createApi } from '@reduxjs/toolkit/query/react'
83+
```
84+
85+
### What's included
86+
87+
RTK Query includes these APIs:
88+
89+
- `createApi()`: The core of RTK Query's functionality. It allows you to define a set of endpoints describe how to retrieve data from a series of endpoints, including configuration of how to fetch and transform that data. In most cases, you should use this once per app, with "one API slice per base URL" as a rule of thumb.
90+
- `fetchBaseQuery()`: A small wrapper around fetch that aims to simplify requests. Intended as the recommended baseQuery to be used in createApi for the majority of users.
91+
- `<ApiProvider />`: Can be used as a Provider if you do not already have a Redux store.
92+
- `setupListeners()`: A utility used to enable refetchOnMount and refetchOnReconnect behaviors.
93+
94+
See the [**RTK Query Overview**](https://redux-toolkit.js.org/rtk-query/overview) page for more details on what RTK Query is, what problems it solves, and how to use it.
95+
6796
## Documentation
6897

6998
The Redux Toolkit docs are available at **https://redux-toolkit.js.org**.

0 commit comments

Comments
 (0)