tRPC

T

tRPC

Join the community to ask questions about tRPC and get answers from other members.

Join

wsLink with external (custom) websocket?

I want to integrate an external websocket to tRPC for extra type-safety with wsLink where the url will need to be dynamic and the authentication as well. The problem is as follows: 1) The websocket url is dynamic. It needs to be requested through an API first to get it, because the system has multiple nodes with different ports....

Error trying to serve TRPC from custom path in Hono

I'm successfully serving a basic "hello world" using the default root path: ```proxyApp.use("/trpc/*", trpcServer({ router: appRouter,...

Next JS error handling.

I'm having this weird error in Next dev whenever I throw an error in a router. ``` login: publicProcedure.input(loginSchema).mutation(async ({ ctx, input }) => { const { error } = await ctx.supabase.auth.signInWithPassword({...
No description

bigint

My trpc client is showing type never for bigints. How can I fix this? Thanks...

trpc+solidjs

I've been happily using trpc v10 with solidjs. now that v11 is officially out, what's the best way to use trpc with solid? is the vanilla client + manual tanstack query integration the way to go?

Best way to wrap procedure for error handling

Wondering what's the most idiomatic way to accomplish this? I want to have a try { } catch {} that wraps each procedure and returns a generic error for uncaught (non trpc) errors It is to just created a wrapper fn ie withErrorHandling that you wrap all your procedures with? ...

procedures on routers are typed any

I'm using the better-t-stack. It also uses turborepo for trpc.
No description

Inferring Types not working as expected

Hi guys, For some reason inferRouterOutputs is not working as expected for me. Environment: react-native, bun, trpc 11...

Error: Switched to client rendering because the server rendering errored: UNAUTHORIZED

What could be the possible reason for this error? This is how my NextJS structure looks when using tRPC. - /app/settings/page.tsx...
No description

Max number of subscriptions

Hello, I hope you can help me. I have a nextjs app with a realtime chat and I've just switched to sse (like in the example repo in the docs) from a standalone ws server. I've implemented various subscriptions, onAdd, onEdit, onDelete, onType and so on. Everithing works on their own but when i try to enable more then 5 subscriptions at the same time the page breaks ( no longer receiving mutation response, no longer able to reload the page, some external api is left pending) . Is there a limit of subscriptions i can run simultaneously? I already have solved the problem consolidating in 2 or 3 subscriptions the whole logic and it works no problem. It would be nice to know if there is a limit tho. Thanks 😃 running on node 22.14 with npm and nextjs v15.3...

TRPCError: Unsupported GET-request to mutation procedure at path

Hi, since I upgraded to TRPC v11 and React Query v5 with the classic integration, I suddenly get lots of errors like these: TRPCError: Unsupported GET-request to mutation procedure at path "app.trackMetric" ...

Context and TanStack

I am having trouble creating the appropriate context with the tanstack query client. The documentation says to use a type that asks for a NextApiResponse but all I can get is a plain NextResponse. Is there something I'm missing?

TRPC 11 Classic React Query custom hook

This is how I was able to refactor one of the custom hooks I had before, typescript threw an error ofc. old approach ```export const useGlassDiameters = < T extends DecoratedQuery<{...

signup/signin

I'm using theo's t3 stack and i'm wondering about user authentication. When signing in or up users, should i prefer nextjs's server actions or trpc ?...

Pre-rendering Error with TRPC useSuspenseQuery – "fetch failed" During Build

Summary During the build process, the application attempts to pre-render the page containing the Greeting component. Since the component uses useSuspenseQuery to call a TRPC endpoint, pre-rendering triggers the call and results in a "fetch failed" error because the route isn’t available during build time. Known workarounds—switching to useQuery or using prefetch on the page component—prevent the error; however, these solutions are not acceptable in this case. Code Samples...

Continuously sending a request

As you can see on my network tab I already have a thousands request, I followed the Tanstack React Query/Server Components . And for the other screenshot that I provided, those are the only changes I made....
No description

Error using prefetch query with TanStack Query

When trying to prefetch data with TanStack Query it fails with the following:
A query that was dehydrated as pending ended up rejecting. [[["tradeList"],{"type":"query"}]]: TypeError: (0 , __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$next$40$15$2e$3$2e$0_react$2d$dom$40$19$2e$1$2e$0_react$40$19$2e$1$2e$0_$5f$react$40$19$2e$1$2e$0$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$rsc$2f$react$2e$js__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__.createContext) is not a function; The error will be redacted in production builds
⨯ [Error: redacted] { digest: '2062921512' }
A query that was dehydrated as pending ended up rejecting. [[["tradeList"],{"type":"query"}]]: TypeError: (0 , __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$next$40$15$2e$3$2e$0_react$2d$dom$40$19$2e$1$2e$0_react$40$19$2e$1$2e$0_$5f$react$40$19$2e$1$2e$0$2f$node_modules$2f$next$2f$dist$2f$server$2f$route$2d$modules$2f$app$2d$page$2f$vendored$2f$rsc$2f$react$2e$js__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__.createContext) is not a function; The error will be redacted in production builds
⨯ [Error: redacted] { digest: '2062921512' }
...

CreateCaller for router with AWS Adapters

Hey - I'm trying to make a create caller. But I'm unsure how I am supposed to pass the correct context information into the create caller. Seemingly no matter what I try it to pass into the createCaller() - it gives me a long error :/...
No description

Wrong type for results

I have a query that has a couple fields with the Date type, however when queried with TanStack they are being returned as string. Is there a way to cast them to Date again?
Solution:
Afaik you need to use a transformer https://trpc.io/docs/server/data-transformers...
Next