Query Docs
Examples
- Simple
- Basic
- Basic w/ GraphQL-Request
- Auto Refetching / Polling / Realtime
- Optimistic Updates
- Pagination
- Load-More & Infinite Scroll
- Infinite query with Max pages
- Suspense
- Default Query Function
- Playground
- Prefetching
- Star Wars
- Rick And Morty
- Next.js Pages
- Next.js app with prefetching
- Next.js app with streaming
- React Native
- React Router
- Offline Queries and Mutations
- Algolia
- Shadow DOM
- Devtools Embedded Panel
- Chat example (streaming)
- Batching
React Example: Nextjs
import React from 'react'
import { QueryClient, dehydrate, noop } from '@tanstack/react-query'
import { Header, InfoBox, Layout, PostList } from '../components'
import { postsQueryOptions } from '../hooks/usePosts'
const Home = () => {
return (
<Layout>
<Header />
<InfoBox>ℹ️ This page shows how to use SSG with React-Query.</InfoBox>
<PostList />
</Layout>
)
}
export async function getStaticProps() {
const queryClient = new QueryClient()
await queryClient.query(postsQueryOptions(10)).catch(noop)
return {
props: {
dehydratedState: dehydrate(queryClient),
},
}
}
export default Home