MCPcopy Create free account
hub / github.com/TanStack/query / getQueryClient

Function getQueryClient

integrations/react-next-15/app/providers.tsx:12–24  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10let browserQueryClient: QueryClient | undefined = undefined
11
12function getQueryClient() {
13 if (isServer) {
14 // Server: always make a new query client
15 return makeQueryClient()
16 } else {
17 // Browser: make a new query client if we don't already have one
18 // This is very important, so we don't re-make a new client if React
19 // suspends during the initial render. This may not be needed if we
20 // have a suspense boundary BELOW the creation of the query client
21 if (!browserQueryClient) browserQueryClient = makeQueryClient()
22 return browserQueryClient
23 }
24}
25
26export default function Providers({ children }: { children: React.ReactNode }) {
27 // NOTE: Avoid useState when initializing the query client if you don't

Callers 1

ProvidersFunction · 0.70

Calls 1

makeQueryClientFunction · 0.90

Tested by

no test coverage detected