@ydtb/tk-scope-query-client
v0.14.0
Published
Shared TanStack Query client singleton for the monorepo.
Downloads
329
Readme
Query Client
Shared TanStack Query client singleton for the monorepo.
Purpose
- Single QueryClient instance shared across shell and all tools
- Cache coordination to prevent duplicate network requests
- Consistent query configuration defaults
Usage
// In shell or any tool
import { QueryClientProvider, useQuery } from '@tanstack/react-query'
import { queryClient } from '@ydtb/query-client'
function App() {
return (
<QueryClientProvider client={queryClient}>
<YourApp />
</QueryClientProvider>
)
}Configuration
Default query options:
staleTime: 1 minutegcTime: 5 minutes (cache retention)refetchOnWindowFocus: falseretry: 3 (queries), 1 (mutations)
Module Federation
This singleton is configured as a shared dependency in Module Federation:
// vite.config.ts
shared: {
'@tanstack/react-query': {
singleton: true,
requiredVersion: '^5.0.0',
strictVersion: true,
},
'@ydtb/query-client': {
singleton: true,
requiredVersion: '^0.0.1',
},
}Status
✅ Initial QueryClient singleton with default configuration
