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

_app.tsx

30 lines741 Bytes

1import React from 'react'
2import {
3 HydrationBoundary,
4 QueryClient,
5 QueryClientProvider,
6} from '@tanstack/react-query'
7import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
8import type { AppProps } from 'next/app'
9​
10export default function MyApp({ Component, pageProps }: AppProps) {
11 const [queryClient] = React.useState(
12 () =>
13 new QueryClient({
14 defaultOptions: {
15 queries: {
16 staleTime: 60 * 1000,
17 },
18 },
19 }),
20 )
21​
22 return (
23 <QueryClientProvider client={queryClient}>
24 <HydrationBoundary state={pageProps.dehydratedState}>
25 <Component {...pageProps} />
26 </HydrationBoundary>
27 <ReactQueryDevtools />
28 </QueryClientProvider>
29 )