Skip to content
0

katanakit-js / useCreateQueryClient

Function: useCreateQueryClient() ​

ts
function useCreateQueryClient(config?): QueryClient;

Defined in: src/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.

Parameters ​

ParameterTypeDescription
configQueryClientConfigTanStack QueryClientConfig (caches, default options).

Returns ​

QueryClient

A fresh QueryClient.

Example ​

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

Released under the MIT License.