Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

installation.md

99 lines2.0 KB

1---
2id: installation
3title: Installation
4---
5​
6You can install React Query via [NPM](https://npmjs.com/),
7or a good ol' `<script>` via
8[ESM.sh](https://esm.sh/).
9​
10### NPM
11​
12```bash
13npm i @tanstack/react-query
14```
15​
16or
17​
18```bash
19pnpm add @tanstack/react-query
20```
21​
22or
23​
24```bash
25yarn add @tanstack/react-query
26```
27​
28or
29​
30```bash
31bun add @tanstack/react-query
32```
33​
34[//]: # 'Compatibility'
35​
36React Query is compatible with React v18+ and works with ReactDOM and React Native.
37​
38> Wanna give it a spin before you download? Try out the [simple](./examples/simple) or [basic](./examples/basic) examples!
39​
40[//]: # 'Compatibility'
41​
42### CDN
43​
44If you're not using a module bundler or package manager, you can also use this library via an ESM-compatible CDN such as [ESM.sh](https://esm.sh/). Simply add a `<script type="module">` tag to the bottom of your HTML file:
45​
46[//]: # 'CDNExample'
47​
48```html
49<script type="module">
50 import React from 'https://esm.sh/react@18.2.0'
51 import ReactDOM from 'https://esm.sh/react-dom@18.2.0'
52 import { QueryClient } from 'https://esm.sh/@tanstack/react-query'
53</script>
54```
55​
56> You can find instructions on how to use React without JSX [here](https://react.dev/reference/react/createElement#creating-an-element-without-jsx).
57​
58[//]: # 'CDNExample'
59​
60### Requirements
61​
62React Query is optimized for modern browsers. It is compatible with the following browsers config
63​
64```
65Chrome >= 91
66Firefox >= 90
67Edge >= 91
68Safari >= 15
69iOS >= 15
70Opera >= 77
71```
72​
73> Depending on your environment, you might need to add polyfills. If you want to support older browsers, you need to transpile the library from `node_modules` yourselves.
74​
75### Recommendations
76​
77It is recommended to also use our [ESLint Plugin Query](../../eslint/eslint-plugin-query.md) to help you catch bugs and inconsistencies while you code. You can install it via:
78​
79```bash
80npm i -D @tanstack/eslint-plugin-query
81```
82​
83or
84​
85```bash
86pnpm add -D @tanstack/eslint-plugin-query
87```
88​
89or
90​
91```bash
92yarn add -D @tanstack/eslint-plugin-query
93```
94​
95or
96​
97```bash
98bun add -D @tanstack/eslint-plugin-query
99```