Skip to content

UseCreateQueryClient

katanakit-js / useCreateQueryClient

function useCreateQueryClient(config?): QueryClient;

Defined in: core/services/query.service.ts:172

Creates a new QueryClient. Use this on the server (SSR) to get one client per request and avoid sharing a process-global cache across users.

Parameter Type Description
config? QueryClientConfig TanStack QueryClientConfig (caches, default options).

QueryClient

A fresh QueryClient.

// Server: one client per request, then dehydrate/hydrate.
const client = useCreateQueryClient();
await client.prefetchQuery({ queryKey, queryFn });
const state = dehydrate(client);