Skip to content

Commit e59a273

Browse files
committed
fix: 'No QueryClient set, use QueryClientProvider to set one' issue passing the useQuery hook from the consuming app
1 parent 376b3e0 commit e59a273

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@creatorem/next-trpc",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/creatorem/next-trpc"
@@ -62,10 +62,10 @@
6262
"server-only": "^0.0.1",
6363
"ts-jest": "^29.4.6",
6464
"turbo": "^2.6.3",
65+
"@tanstack/react-query": "5.90.12",
6566
"typescript": "~5.9.2"
6667
},
6768
"peerDependencies": {
68-
"@tanstack/react-query": "5.90.12",
6969
"next": "16.0.8",
7070
"zod": "^3.25.76"
7171
},

src/create-trpc-query-client.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { useQuery } from "@tanstack/react-query";
3+
import type { useQuery as useQueryType } from "@tanstack/react-query";
44
import {
55
type EndpointClient,
66
createTrpcClientOptions,
@@ -13,11 +13,11 @@ type TrpcClientWithQuery<R extends Router<any>> = {
1313
? EndpointClient<Input, Output> & {
1414
useQuery: (
1515
queryOptions?: Omit<
16-
Parameters<typeof useQuery>[0],
16+
Parameters<typeof useQueryType>[0],
1717
"queryKey" | "queryFn"
1818
>
1919
) => ReturnType<
20-
typeof useQuery<Promise<Output>, Error, Promise<Output>, string[]>
20+
typeof useQueryType<Promise<Output>, Error, Promise<Output>, string[]>
2121
>;
2222
}
2323
: never;
@@ -26,7 +26,7 @@ type TrpcClientWithQuery<R extends Router<any>> = {
2626
export const createTrpcQueryClient = <
2727
R extends ReturnType<typeof router<any, Router<any>>>
2828
>(
29-
opts: createTrpcClientOptions
29+
opts: createTrpcClientOptions & {useQuery: typeof useQueryType}
3030
): TrpcClientWithQuery<R> => {
3131
return new Proxy({} as TrpcClientWithQuery<R>, {
3232
get(target, prop) {
@@ -38,12 +38,12 @@ export const createTrpcQueryClient = <
3838
}),
3939
useQuery: (
4040
queryOptions?: Omit<
41-
Parameters<typeof useQuery>[0],
41+
Parameters<typeof useQueryType>[0],
4242
"queryKey" | "queryFn"
4343
>
4444
) => {
4545
const endpointName = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
46-
return useQuery({
46+
return opts.useQuery({
4747
...queryOptions,
4848
queryKey: [endpointName],
4949
queryFn: getTrpcFetch({

0 commit comments

Comments
 (0)