No QueryClient set React Origin: On your device Last updated 12 Oct 2026

Error: No QueryClient set, use QueryClientProvider to set one

TanStack Query hooks ran outside a QueryClientProvider (or a duplicate copy of the library is installed).

Exact message you may see No QueryClient set, use QueryClientProvider to set one
Seen on: React

Meaning

useQuery needs the client from context. Missing provider, tests without it, or two versions of @tanstack/react-query (separate contexts) cause it.

Common causes

  • QueryClientProvider missing at the root
  • Tests rendering without a provider
  • Duplicate library versions / monorepo duplicates

⚡ Quick fix

  1. Wrap the app in <QueryClientProvider client={queryClient}>
  2. Provide a wrapper in tests
  3. Deduplicate with npm ls @tanstack/react-query

Detailed fix by platform

React

  1. jsx
    const queryClient = new QueryClient();
    <QueryClientProvider client={queryClient}><App /></QueryClientProvider>

How to diagnose

  1. Provider — At the root?
  2. Copies — One library version?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Adjacent JSX elements — Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? (React)Adjacent JSX elementsFlask app context — RuntimeError: Working outside of application context. (Python)Flask app contextnot wrapped in act — Warning: An update to Component inside a test was not wrapped in act(...) (React)not wrapped in actsetState during render — Warning: Cannot update a component (`Parent`) while rendering a different component (`Child`) (React)setState during renderuncontrolled to controlled — Warning: A component is changing an uncontrolled input to be controlled (React)uncontrolled to contr…useContext undefined — TypeError: Cannot destructure property 'user' of 'useContext(...)' as it is undefined. (React)useContext undefineduseNavigate outside Router — Error: useNavigate() may be used only in the context of a <Router> component. (React)useNavigate outside R…No QueryC…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.