tRPC

T

tRPC

Move Fast & Break Nothing. End-to-end typesafe APIs made easy.

Join

Handle React error boundary

Seems like Im doing something wrong as I can't handle the error boundary from trpc query. I've queryClient with useErrorboundary set to true and wrapped my component that uses trpc query with the React Error Boundary but it doesn't seem to be able to catch it. When I just throw before the query it successfully intercepts the error but from trpc seems its not doing that? Am I doing something wrong ?? ```js const [queryClient] = useState(...

Any tips for Typescript slowness?

We successfully migrated from 9.x to 10 but are still seeing slow VS Code perf (10+ seconds to get any type info) are there any strategies we can use to minimize this?

Change status of useMutation from 'success' back to 'idle'

Hiya, I have a mutation for creating stuff that can run a few different ways on a page, and I want to change its 'success' status back to 'idle' after 5 seconds. Is there a programmatic way to change a mutation's status from 'success' back to 'idle'?

Is it possible to call one procedure in another?

I have multiple routers in my trpc server. For example userRouter (e.g. procedure: getUser) and postRouter (e.g. procedure: updatePost). Is it possible to call the getUser procedure from my userRouter in my updatePost procedure? Or are all procedure effectively independent....

Handling Query Errors at Root of App (v9)

I want to show an error toast on my NextJS frontend every time there is an error from useQuery in a functional component. Is there a way to add something at the root of my app that can watch for trpc errors or do I have to handle it at every use of useQuery? (note: i am on v9)

tRPC Client webpack error

As soon as I add the client part to my legacy app i get an error and Can't figure out what is wrong. ```js Version: webpack 4.35.3 ......

cookies, headers and authentication

in express I can do something like res.cookie("name", "value") for example. alternatively I can do res.set"set-cookie", "name=value"). how can I do something one of the two above with trpc? ...

remove query

is there any api on the trpc client to instantly remove the query out of the query cache? Basically this https://tanstack.com/query/v4/docs/reference/QueryClient#queryclientremovequeries

trpc hook pattern. This works, but I’m not convinced…

I want to call my route when a button is clicked and have access to isLoading, onError etc… I have implemented a pattern using ‘’refetch()’’ but it doesn’t feel ‘correct’ is there a better way of doing this. I will also create a custom hook out of it. ‘’’js const { refetch } = trpc.authDomain.signIn.useQuery( { email: userEmail },...

Catch TRPCError, ZoddError on the front-end

i am throwing a TRPCError in a mutation. i dont understand how to catch this error in the OnError method. Please help me with this. i have the following: ServerSide...

implicitly has type 'any' because it does not have a type annotation and is referenced directly

Running into this error. I feel like it's some sort of infinite recursion issue, but not sure where to look for the cause

Why do some examples create PrismaClient in context, and others don’t

Is there a specific reason to do this or not to do this? I can imagine with the new Prisma extension feature you could do some handy things like attaching multi tenancy data to each query beforehand

AppRouter type any?

I am trying to use trpc in a Turbo repo and when I export the AppRouter on the server side it is the correct type but when it is imported to the client side it infers type any. The AppRouter is being import from another app in my pnpm workspace.

z.map() as an input

Hi, I have
z.map(z.string(), z.string())
z.map(z.string(), z.string())
...

How to call TRPC procedures directly, without creating a router and calling createCaller?

I'd like to use a TRPC procedure by calling it directly like someProcedure({input, ctx}) We frequently call TRPC procedures from within other TRPC procedures....

correct way to call TRPC inside a function

i want a user to be able to sign after they have a clicked a button but i get a hooks error. can anyone help with this?

Cannot find namespace 'trpc'

I'm getting this error when trying to access <trpc.Provider ...>. Any idea what might be going on?

use tRPC for RPC calls instead of gRPC

Hi, I know that tRPC and gRPC are different things - despite the similar name. Nevertheless I would like to hear your opinion on using tRPC for things you would normally use gRPC for. What are possible use cases? What are the pros and cons....

tRPC caching vs Vercel dynamic edge caching

What is the difference, or improvements, on Vercel's dynamic edge caching? tRPC server caching works without it. What is the difference? I don't understand

Ignore Errors from batch calls

I have some of my routers throw helpful errors for the client to use in the error message object, but when one of those calls in a batch request, it causes the other calls to fail and never resolves. How do you get around that? I'd rather not add a nullable error field to all my results