tRPC

T

tRPC

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

Join

Is there a way to split a trpc api across multiple lambdas ?

How do I go about splitting my TRPC api across multiple lambdas, such that each lambda would load the minimum code it needs to run, (ideally the frontend should not be affected )

Can I alter the context in a procedure?

Is there a proper way to do this? Mutating the opts.ctx directly seems wrong

tRPC & getInitialProps

So I am not using Next new App router but cant figure it out how to call a method during SSR with getInitialProps. Does anybody know how that works?

Getting 413 error in Vercel when batching several queries (using Next pages router)

Hi guys, I'm having a weird error on Vercel: "LAMBDA_RUNTIME Failed to post handler success response. Http response code: 413." ...

Queries work but mutations do not

Odd bug I'm experiencing with TRPC + react-query + the koa adapter. I just set everything up per docs. I tried out a test query and a test mutation, both with very simple input validated by Zod. The query hits the backend route but the mutation never does - even if I change the inputs, etc. Does anyone have any idea where to look for the culprit here?

useContext utils getData always returning undefined

I have my app set up with TRPC and when trying to call const utils = trpc.useContext(); const cart = utils.cart.getCart.getData();...

TRPC Error Handling

I am using TRPC as my backend for my nextjs application. The one major problem i am facing is that, whenever I throw a new TRPC error, it crashes my frontend completely. I wanted to know whether, there is a better of handling errors and getting error message in a text ? I am using TRPC with react query in the frontend Nextjs client and serving the api with a TRPC Express App....

CORS issue with Lambda Handler (SST)

no idea what's going on with this error. been stuck on it for way too long. i tried adding the test-header to the server side but not seeing it come through? should that happen?
i went through this issue but doesn't seem to work for me ```...
No description

TRPC API not working for production build

I am using Trpc and next in project, The App is fully functional with dev build , but api's giving 400 BAD Request on production build done with docker, I am doing standalone next js build I tried to debug., follow other examples but not able to figure it out any issue ...

Get object type using UseTRPCQueryResult

this code ```ts type playlistOutputData = UseTRPCQueryResult< inferRouterOutputs<AppRouter>["notifications"]["getUserNotifications"], TRPCClientErrorLike<AppRouter>["data"] >["data"];...

Need help with type hinting a function that accepts a trpc client router

```js interface CreateModelProps<GetResult> { name: string, procedures: DecoratedProcedureRecord<{ read: BuildProcedure<"query", any, any>...

Database error on examples-next-prisma-starter

Hi, im on node 18.16.0. I'm trying to clone and use this : https://github.com/trpc/examples-next-prisma-starter I'm following the README but unfortunately I got an error : Error: P1001: Can't reach database server at localhost:5432 I guess there is something I'm missing, I supposed the project would automatically create and run a local DB server but it seems to not be the case.
Any clues ^^ ?...

Set server response headers from TRPC standalone adapter

Hi I am trying to implement my own authentication in Trpc. For this I need to create a session on the backend and return appropriate headers like set cookie for session-token and csrf-token. How can I set these headers from within a mutation when using the standalone adapter.
...

Return TRPC Error from NextJS middleware

I am using trpc for my app's api but Im using NextJS middleware + upstash ratelimitting for.... well ratelimitting. Is there a way return a TRPC error from the middleware route?

useContext not Invalidating

What are the possible mistakes if useContext wont invalidate when doing the following: ```ts const utils = trpc.useContext(); const user = trpc.user.getUser.useQuery(); const updateUser = trpc.user.updateUser.useMutation({...

Deduping is broken, but is being batched

Hi all, We're using TRPC for our React Native app, while doing some testing, I saw in my server logs that the requests don't seem to be deduplicated on the client side, but are batched to the server. ```...

Question about trpc revalidation method

alright I have a question, why can tRPC detect changes from the DB and refetch. but when I mutate the DB from the client I need to manually invalidate()?

How can I enable experimental Suspense on NextJS

O have a project with trpc (v.10^) and nextjs 13, and I wanna test the suspense query, but not show for me, just the normal useQuery.

Examples of Vitest with React Testing Library

Does anyone have examples of how to mock data from tRPC procedure calls? I have client components that are fetching data using tRPC , and I want to run integration tests. I have been attempting to use vi.mock() to mock this data but I haven't gotten it to work correctly. Thanks in advance! https://vitest.dev/guide/mocking.html...

How to refetch based on different event

I have a procedure that fetches all products, I have another one that deletes a project given it's ID, these two are used on the same page, how can tell tRPC to rerun the allProducts request when a delete happens. currently I need to refresh to see the product get deleted, in case that's not what's supposed to happen please tell me. I am using the pages router and tRPC v10...