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

index.js

420 lines18.1 KB

1import * as React from 'react'
2import { ParentSize } from '@visx/responsive'
3import Head from 'next/head'
4import Link from 'next/link'
5​
6//
7import { siteConfig } from '../siteConfig'
8​
9import { Banner } from '../components/Banner'
10import { Sticky } from '../components/Sticky'
11import { Nav } from '../components/Nav'
12import { Footer } from '../components/Footer'
13import { ClientsMarquee } from '../components/clients/ClientsMarquee'
14import { Seo } from '../components/Seo'
15​
16const Home = ({ sponsors }) => {
17 return (
18 <>
19 <Seo
20 title="React Query"
21 description="Hooks for fetching, caching and updating asynchronous data in React"
22 />
23 <Head>
24 <title>
25 React Query - Hooks for fetching, caching and updating asynchronous
26 data in React
27 </title>
28 </Head>
29 <div className="bg-gray-50 h-full min-h-full">
30 <Banner />
31 <Sticky>
32 <Nav />
33 </Sticky>
34 <div className="relative bg-white overflow-hidden">
35 <div className="py-24 mx-auto container px-4 sm:mt-12 relative">
36 <img
37 src={require('images/emblem-light.svg')}
38 className="absolute transform right-0 top-1/2 h-0 lg:h-full scale-150 translate-x-1/2 xl:translate-x-1/5 -translate-y-1/2"
39 alt="React Query Emblem"
40 />
41 <div className="grid grid-cols-12 lg:gap-8">
42 <div className="col-span-12 lg:col-span-6 ">
43 <div className="text-center lg:text-left md:max-w-2xl md:mx-auto ">
44 <h1 className="text-4xl tracking-tight leading-10 font-extrabold text-gray-900 sm:leading-none sm:text-6xl lg:text-5xl xl:text-6xl">
45 Performant and powerful data
46 <br className="hidden md:inline xl:hidden" />{' '}
47 <span>synchronization for React</span>
48 </h1>
49 <p className="mt-3 text-base text-gray-700 sm:mt-5 sm:text-xl lg:text-lg xl:text-xl">
50 Fetch, cache and update data in your React and React Native
51 applications all without touching any "global state".
52 </p>
53​
54 <div className="mt-5 mx-auto sm:flex sm:justify-center lg:justify-start lg:mx-0 md:mt-8">
55 <div className="rounded-md shadow">
56 <Link href="/overview">
57 <a className="w-full flex items-center justify-center px-8 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-white bg-coral hover:bg-coral-light focus:outline-none focus:border-coral focus:shadow-outline-coral transition duration-150 ease-in-out md:py-4 md:text-lg md:px-10">
58 Get Started
59 </a>
60 </Link>
61 </div>
62 <div className="mt-3 rounded-md shadow sm:mt-0 sm:ml-3">
63 <a
64 href={siteConfig.repoUrl}
65 target="_blank"
66 rel="noopener noreferrer"
67 className="w-full flex items-center justify-center px-8 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-coral bg-white hover:text-coral-light focus:outline-none focus:border-coral-light focus:shadow-outline-coral transition duration-150 ease-in-out md:py-4 md:text-lg md:px-10"
68 >
69 GitHub
70 </a>
71 </div>
72 </div>
73 <div className="mt-5">
74 <p>
75 Still using v2? No problem!{' '}
76 <a
77 href="https://react-query-v2.tanstack.com/docs/overview"
78 className="text-blue-600 font-semibold transition-colors duration-150 ease-out"
79 >
80 Find the v2 docs here.
81 </a>
82 </p>
83 </div>
84 </div>
85 </div>
86 </div>
87 </div>
88 </div>
89 <div className="text-lg border-t border-gray-200 bg-gray-50 ">
90 <div className="py-24 ">
91 <div className="mx-auto container">
92 <div className="lg:grid lg:grid-cols-3 lg:gap-8">
93 <div>
94 <div>
95 <h3 className="text-xl leading-6 xl:text-2xl font-bold text-gray-900">
96 Declarative & Automatic
97 </h3>
98 <p className="mt-2 lg:mt-4 text-base xl:text-lg lg:leading-normal leading-6 text-gray-600">
99 Writing your data fetching logic by hand is over. Tell
100 React Query where to get your data and how fresh you need
101 it to be and the rest is automatic. React Query handles
102 caching, background updates and stale data out of the box
103 with zero-configuration.
104 </p>
105 </div>
106 </div>
107 <div className="mt-10 lg:mt-0">
108 <div>
109 <h3 className="text-xl leading-6 xl:text-2xl font-bold text-gray-900">
110 Simple & Familiar
111 </h3>
112 <p className="mt-2 lg:mt-4 text-base xl:text-lg lg:leading-normal leading-6 text-gray-600">
113 If you know how to work with promises or async/await, then
114 you already know how to use React Query. There's no global
115 state to manage, reducers, normalization systems or heavy
116 configurations to understand. Simply pass a function that
117 resolves your data (or throws an error) and the rest is
118 history.
119 </p>
120 </div>
121 </div>
122 <div className="mt-10 lg:mt-0">
123 <div>
124 <h3 className="text-xl leading-6 xl:text-2xl font-bold text-gray-900">
125 Powerful & Configurable
126 </h3>
127 <p className="mt-2 lg:mt-4 text-base xl:text-lg lg:leading-normal leading-6 text-gray-600">
128 React Query is configurable down to each observer instance
129 of a query with knobs and options to fit every use-case.
130 It comes wired up with dedicated devtools,
131 infinite-loading APIs, and first class mutation tools that
132 make updating your data a breeze. Don't worry though,
133 everything is pre-configured for success!
134 </p>
135 </div>
136 </div>
137 </div>
138 </div>
139 </div>
140 <div className="py-6">
141 <div className="uppercase tracking-wider text-sm font-semibold text-center text-gray-400 mb-3">
142 Trusted in Production by
143 </div>
144​
145 <ClientsMarquee />
146 </div>
147 </div>
148 <div className="bg-gray-900 text-white">
149 <div className="py-32">
150 <div className="mx-auto container text-center">
151 <div className="text-xl">ANNOUNCING</div>
152 <div className="text-3xl md:text-5xl font-bold">
153 React Query Essentials
154 </div>
155 <div className="text-xl italic">
156 The <strong>official</strong> React Query course by{' '}
157 <strong>Tanner Linsley</strong>
158 </div>
159 <a
160 href="https://learn.tanstack.com"
161 className="inline-block mt-8 rounded shadow-lg bg-coral text-white font-bold text-xl px-4 py-3"
162 >
163 ENROLL NOW
164 </a>
165 <div className="grid pt-8 text-white max-w-screen-lg mx-auto text-lg">
166 <span className="mb-2">
167 <span className="bg-coral text-gray-800 w-4 h-4 mr-2 rounded-full inline-flex items-center justify-center">
168 <Check />
169 </span>
170 50+ Lessons
171 </span>
172 <span className="mb-2">
173 <span className="bg-coral text-gray-800 w-4 h-4 mr-2 rounded-full inline-flex items-center justify-center">
174 <Check />
175 </span>
176 3+ Hours of Live-Code Training
177 </span>
178 <span className="mb-2">
179 <span className="bg-coral text-gray-800 w-4 h-4 mr-2 rounded-full inline-flex items-center justify-center">
180 <Check />
181 </span>
182 Lesson Source Code
183 </span>
184 <span className="mb-2">
185 <span className="bg-coral text-gray-800 w-4 h-4 mr-2 rounded-full inline-flex items-center justify-center">
186 <Check />
187 </span>
188 Full API coverage
189 </span>
190 </div>
191 </div>
192 </div>
193 </div>
194 <div className="relative text-lg border-t border-gray-200 bg-gray-100 overflow-hidden">
195 <div className="lg:block lg:absolute lg:inset-0">
196 <svg
197 className="absolute top-1/2 left-1/2 transform -translate-y-1/2 -translate-x-1/2"
198 width="2400"
199 height="2400"
200 fill="none"
201 viewBox="0 0 2400 2400"
202 >
203 <defs>
204 <pattern
205 id="9ebea6f4-a1f5-4d96-8c4e-4c2abf658047"
206 x="0"
207 y="0"
208 width="20"
209 height="20"
210 patternUnits="userSpaceOnUse"
211 >
212 <rect
213 x="0"
214 y="0"
215 width="4"
216 height="4"
217 className="text-gray-200"
218 fill="currentColor"
219 />
220 </pattern>
221 </defs>
222 <rect
223 x="0"
224 width="2400"
225 height="2400"
226 fill="url(#9ebea6f4-a1f5-4d96-8c4e-4c2abf658047)"
227 />
228 </svg>
229 </div>
230 <div className="relative">
231 <h3 className="text-center text-3xl leading-8 font-extrabold tracking-tight text-gray-900 sm:text-4xl sm:leading-10 lg:leading-none mt-8">
232 Sponsors
233 </h3>
234 <div className="py-4 flex flex-wrap max-w-screen-md mx-auto">
235 <ParentSize>
236 {({ width }) => {
237 return (
238 <iframe
239 title="sponsors"
240 src="https://tanstack.com/sponsors-embed"
241 style={{
242 width: width,
243 height: width,
244 overflow: 'hidden',
245 }}
246 />
247 )
248 }}
249 </ParentSize>
250 </div>
251 <div className="text-center mb-8">
252 <a
253 href="https://github.com/sponsors/tannerlinsley"
254 className="inline-block bg-green-500 px-4 py-2 text-xl mx-auto leading-tight font-extrabold tracking-tight text-white rounded-full"
255 >
256 Become a Sponsor!
257 </a>
258 </div>
259 </div>
260 </div>
261​
262 <div className="bg-gray-100 relative py-24 border-t border-gray-200 ">
263 <div className="px-4 sm:px-6 lg:px-8 mx-auto container max-w-3xl sm:text-center">
264 <h3 className="text-3xl leading-8 font-extrabold tracking-tight text-gray-900 sm:text-4xl sm:leading-10 lg:leading-none mt-2">
265 Less Code. Fewer Edge Cases.
266 </h3>
267 <p className="my-4 text-xl leading-7 text-gray-600">
268 Instead of writing reducers, caching logic, timers, retry logic,
269 complex async/await scripting (I could keep going...), you
270 literally write a tiny fraction of the code you normally would.
271 You will be surprised at how little code you're writing or how
272 much code you're deleting when you use React Query.
273 </p>
274 </div>
275 <div
276 style={{
277 height: 224,
278 }}
279 />
280 </div>
281​
282 <section className="bg-gray-900 body-font">
283 <div className="container max-w-7xl px-4 mx-auto -mt-72 relative">
284 <iframe
285 src="https://codesandbox.io/embed/github/tannerlinsley/react-query/tree/master/examples/basic?autoresize=1&fontsize=16&theme=dark"
286 title="tannerlinsley/react-query: basic"
287 sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
288 className="shadow-2xl"
289 style={{
290 width: '100%',
291 height: '80vh',
292 border: '0',
293 borderRadius: 8,
294 overflow: 'hidden',
295 position: 'static',
296 zIndex: 0,
297 }}
298 ></iframe>
299 </div>
300 <div className="py-24 px-4 sm:px-6 lg:px-8 mx-auto container">
301 <div className=" sm:text-center pb-16">
302 <h3 className="text-3xl mx-auto leading-tight font-extrabold tracking-tight text-white sm:text-4xl lg:leading-none mt-2">
303 One Dep, All the Features.
304 </h3>
305 <p className="mt-4 text-xl max-w-3xl mx-auto leading-7 text-gray-300">
306 With React as the only dependency, React Query is extremely
307 lean, but also strategically packed to the brim with features
308 you're bound to need in almost any project. From weekend hobbies
309 all the way up to enterprise e-commerce systems (lookin' at you
310 Walmart!), React Query is jam packed with battle-hardened tools
311 to help you succeed.
312 </p>
313 </div>
314 <div>
315 <div className="grid grid-flow-row grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 text-white max-w-screen-lg mx-auto text-lg">
316 {[
317 'Backend agnostic',
318 'Dedicated Devtools',
319 'Auto Caching',
320 'Auto Refetching',
321 'Window Focus Refetching',
322 'Polling/Realtime Queries',
323 'Parallel Queries',
324 'Dependent Queries',
325 'Mutations API',
326 'Automatic Garbage Collection',
327 'Paginated/Cursor Queries',
328 'Load-More/Infinite Scroll Queries',
329 'Scroll Recovery',
330 'Request Cancellation',
331 'Suspense Ready!',
332 'Render-as-you-fetch',
333 'Prefetching',
334 'Variable-length Parallel Queries',
335 'Offline Support',
336 'SSR Support',
337 'Data Selectors',
338 ].map(feature => (
339 <span className="mb-2" key={feature}>
340 <span className="bg-coral text-gray-800 w-4 h-4 mr-2 rounded-full inline-flex items-center justify-center">
341 <Check />
342 </span>
343 {feature}
344 </span>
345 ))}
346 </div>
347 </div>
348 </div>
349 </section>
350 <div className="bg-gray-200 border-b border-gray-300">
351 <div className="container mx-auto py-12 text-center">
352 <h3 className="text-2xl md:text-5xl mx-auto leading-tight font-extrabold tracking-tight text-gray-800 lg:leading-none mt-2">
353 Feeling Chatty?
354 </h3>
355 <a
356 href="https://discord.gg/WrRKjPJ"
357 target="_blank"
358 className="inline-block bg-gray-800 p-5 text-2xl mx-auto leading-tight font-extrabold tracking-tight text-white mt-12 rounded-full"
359 >
360 Join the #TanStack Discord!
361 </a>
362 </div>
363 </div>
364 <div className="bg-gray-50 border-b border-gray-100">
365 <div className="container mx-auto py-24 px-4 flex flex-wrap md:flex-no-wrap items-center justify-between md:space-x-8">
366 <h2 className="text-3xl leading-9 font-extrabold tracking-tight text-gray-900 sm:text-4xl sm:leading-10">
367 Wow, you've come a long way!
368 </h2>
369 <div className="mt-8 flex lg:flex-shrink-0 md:mt-0">
370 <div className="inline-flex rounded-md shadow">
371 <Link href="/overview">
372 <a className="inline-flex items-center justify-center text-center px-5 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-white bg-coral hover:bg-coral-light focus:outline-none focus:shadow-outline transition duration-150 ease-in-out">
373 Okay, let's get started!
374 </a>
375 </Link>
376 </div>
377 <div className="ml-3 inline-flex rounded-md shadow">
378 <a
379 href={siteConfig.repoUrl}
380 className="inline-flex items-center justify-center text-center px-5 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-coral bg-white hover:text-coral-light focus:outline-none focus:shadow-outline transition duration-150 ease-in-out"
381 >
382 Take me to the GitHub repo.
383 </a>
384 </div>
385 </div>
386 </div>
387 </div>
388 <Footer />
389 <style jsx global>{`
390 .gradient {
391 -webkit-mask-image: linear-gradient(
392 180deg,
393 transparent 0,
394 #000 30px,
395 #000 calc(100% - 200px),
396 transparent calc(100% - 100px)
397 );
398 }
399 `}</style>
400 </div>
401 </>
402 )
404​
405export default Home
406Home.displayName = 'Home'
407const Check = React.memo(() => (
408 <svg
409 fill="none"
410 stroke="currentColor"
411 strokeLinecap="round"
412 strokeLinejoin="round"
413 strokeWidth="3"
414 className="w-3 h-3"
415 viewBox="0 0 24 24"
416 aria-hidden="true"
417 >
418 <path d="M20 6L9 17l-5-5"></path>
419 </svg>
420))