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

installation.md

63 lines1.8 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
13$ npm i @tanstack/react-query
14# or
15$ pnpm add @tanstack/react-query
16# or
17$ yarn add @tanstack/react-query
18```
19​
20React Query is compatible with React v18+ and works with ReactDOM and React Native.
21​
22> Wanna give it a spin before you download? Try out the [simple](../examples/react/simple) or [basic](../examples/react/basic) examples!
23​
24### CDN
25​
26If 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:
27​
28```html
29<script type="module">
30 import React from 'https://esm.sh/react@18.2.0'
31 import ReactDOM from 'https://esm.sh/react-dom@18.2.0'
32 import { QueryClient } from 'https://esm.sh/@tanstack/react-query'
33</script>
34```
35​
36> You can find instructions on how to use React without JSX [here](https://react.dev/reference/react/createElement#creating-an-element-without-jsx).
37​
38### Requirements
39​
40React Query is optimized for modern browsers. It is compatible with the following browsers config
41​
42```
43Chrome >= 91
44Firefox >= 90
45Edge >= 91
46Safari >= 15
47iOS >= 15
48Opera >= 77
49```
50​
51> 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.
52​
53### Recommendations
54​
55It is recommended to also use our [ESLint Plugin Query](./eslint/eslint-plugin-query) to help you catch bugs and inconsistencies while you code. You can install it via:
56​
57```bash
58$ npm i -D @tanstack/eslint-plugin-query
59# or
60$ pnpm add -D @tanstack/eslint-plugin-query
61# or
62$ yarn add -D @tanstack/eslint-plugin-query
63```