Loader doesn't get router context
I'm trying to use a TanStack Query queryClient in my loader that I pass through context, but the loader is not detecting the context. I'm wondering if I'm doing anything wrong.
4 Replies
stormy-goldOP•12mo ago
The context in the loader is not typesafe
fascinating-indigo•12mo ago
I believe you didn't add the QueryClient to the root route context in your
__root.tsx
https://tanstack.com/router/latest/docs/framework/react/guide/router-context#how-about-an-external-data-fetching-libraryTanStack | High Quality Open-Source Software for Web Developers
Headless, type-safe, powerful utilities for complex workflows like Data Management, Data Visualization, Charts, Tables, and UI Components.

ratty-blush•12mo ago
yes you need to use
createRootRouteWithContext
stormy-goldOP•12mo ago
Ah ok! Thanks Leonard and Manuel!