# RTK Query ## Установка ```bash filename="Terminal" pnpm i @reduxjs/toolkit react-redux ``` ## Создание стора ```ts filename="src/services/store.ts" import { configureStore } from '@reduxjs/toolkit' export const store = configureStore({ reducer: {}, middleware: getDefaultMiddleware => getDefaultMiddleware(), }) export type AppDispatch = typeof store.dispatch export type RootState = ReturnType ``` ## Подключение стора к приложению ```tsx filename="src/App.tsx" import { Provider } from 'react-redux' import { Router } from '@/router' import { store } from '@/services/store' export function App() { return ( ) } ``` ## Создание Api ```ts filename="src/services/auth/auth.ts" import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react' export const authApi = createApi({ reducerPath: 'authApi', baseQuery: fetchBaseQuery({ baseUrl: 'https://api.flashcards.andrii.es', credentials: 'include', }), endpoints: builder => { return { getMe: builder.query({ query: () => `auth/me`, }), } }, }) export const { useGetMeQuery } = authApi ```