Skip to content
public-library›Rules›TanStack Router›Provide shared dependencies through typed router context

Provide shared dependencies through typed router context

Declare the dependencies routes share, such as the QueryClient and authentication state, as the root route's context type with createRootRouteWithContext, and pass instances when creating the router. Read them from context in loaders and beforeLoad, instead of importing module-level singletons.

In the full rule