tRPC

T

tRPC

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

Join

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

Any way to view headers in middleware?

Middleware input doesn't seem to have it :/

How can I use a fork of trpc-next?

Hey there, I've made a fork of @trpc in order to fix an issue inside of @trpc/next. I can build it and manually use it in my code. However, I'm struggling to reference the package directly from github in yarn. I put the following in my package.json file: ``` "dependencies": { "@trpc/next": "skyriverbend/trpc#commit=9c0f4eb0896f06baeff789a841d4d9ae1b2a6f1b&workspace=@trpc/next",...

trying to cache api routes

Hello. I am using TRPC to make a site which integrates with a third party API. I need to add caching to some of my routes. ...

Prisma+TRPC monorepo

Hey, so we have a monorepo with 3 backend services and 3 frontend services. It looks like the following: - Content frontend - Content backend - Teacher backend - Teacher frontend...

calling api endpoints from within a trpc api endpoint?

Hey all. I have a series of api endpoints which may have to be reused across other api endpoints. I was wondering if this is possible? ```ts...

TRPC waiting until the query has completed

Hey. I've just found out about TRPC and I love it. However, I was wondering if there is a way to make it so the code below my query doesn't run until the query has completed, without having to make an external function or make use of a useeffect hook in order to use await? Is there a property of some sort which I can use to stop the page from rendering? The code below causes an infinite signIn loop due to the data not being there on the initial page render. But, I can't check if !guilds.data, because sometimes it wont return anything, due to an invalid token. Which means there is no good way to identify when to force a signIn for the user....