tRPC

T

tRPC

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

Join

v10 Migration interop, router doesnt have attributes

Hi, i've tried to migrate like stated in the docs, these are my routers. Question: Shouldn't appRouter now have access to the merged routers above?

Recommended file structure for next.js?

Hey all - using tRPC heavily with next.js and it's great. Our main [trpc].ts file is getting huge and unwieldily - wondering what the recommendations are out there for organizing?

Unhandled Runtime ErrorTRPCClientError

Call Stack Function.from node_modules@trpc\client\dist\TRPCClientError-09b8a26b.esm.js (57:0) transformRPCResponse node_modules@trpc\client\dist\httpRequest-62c5cce4.esm.js (15:11)...

Weird error when running unit test

10.0.0-proxy-beta.5 works just fine, error occurs on 10.0.0-proxy-beta.6 with the introduction of @swc/helpers.

Sharing middleware between TRPC servers

We currently have microservices REST API's on Cloudflare Workers and I'm thinking about moving this to TRPC Microservices. We currently have a middleware in a shared package that we can reuse between microservices for authentication, how do I do this within TRPC? How do I define a MiddlewareFunction that can be reused between multiple TRPC instances?...

Is `trpc.withTRPC` for Next supposed to work with pages or only `_app`?

I'd love to only have TRPC mount on certain pages of my Next.js app. Is this currently supported?

TRPClientError

The operation has been aborted at Function. This is the file with the error. The current file is here: https://github.com/makyfj/GymPal/blob/main/src/pages/workout/%5Bid%5D.tsx...

What does the WebSocketHandler do?

I'm not sure what this is doing on the background.

Are there any example of subscriptions working with react native ?

queries and mutations are working pretty well with react native, I'm unable however to get subscriptions to work.

Recommended way to prefetch client-side

In react-query, you can do
queryClient.prefetchQuery(['todos', input], queryFn)
queryClient.prefetchQuery(['todos', input], queryFn)
...

Modifying payload client-side before caching

Say I have a payload that includes something like category_id in each of the items returned e.g.: ``` [ { category_id: 1, ...}, { category_id: 2, ... },...

errorFormatter is not being called?

Could somebody confirm that this callback is called in the latest version? I call it from server side using: const caller = lunaRouter.createCaller({});...

Response headers

Is it possible to modify the response headers from server to client?

API Response caching not working on vercel ⁉

I've followed the instructions in https://trpc.io/docs/v9/caching for API Response caching and it's not working when hosted on vercel. The headers are getting set on localhost which tells me the code is working, but once it's hosted on vercel the cache headers aren't being set. Does anyone have any ideas what's wrong? My code (almost the exact same as the example shown here: https://trpc.io/docs/v9/caching#api-response-caching)...

when throwing a TRPCError, is there a way to include an internal error code ?

for the given screenshot, if such error happens I wanna prompt the user to login or something.

How to divide public and private routes?

I am creating and app that has a dashboard panel for admin, and public routes, for users. Let's say that i have a resource called, "products", admins can add products y users get the details, right now i have something like "products.get", this works fine for the users consumers, but now i want to create and endpoint to get more details (that are not exposed to the users), but i can't use the same path "products.get". So i was looking for some ideas to handle this case, maybe create a router "private", and add all the protected resources there? and another one public?. this will give me something like "private.products.get" and "public.products.get"... but idk, maybe there is abetter option...

Websocket connection failed.

I'm following the websocket's example and it works fine as it is, however I changed some things and it seems i broke it. The problem is located in the getinitialprops function in _myapp.tsx. The thing is I don't want to use authentication and so I don't need to return session as pageprops in the getInitialProps function so I tried returning an empty object but it gives me an error saying failed to connect to 'ws://localhost:3001/'. I should return something as pageProps so the problem goes away but I don't know what and I couldn't find anything in nextjs documentation. I'm not sure if this is related to tRPC and I'm not smart enough to solve it myself so if you have some idea what it's happening I'd appreciate the help. Thank you!...

extra json property added after data when consuming a query hook.

I have this issue where when consuming a RQ hook there is an extra json object that I have to use to access the data & it does not exist on the type.

Problem using next+ssg

Hi, Im trying to use the @trpc/next SSG Helper and I get content on the page. Although I noticed that transition between pages are kind of slow, plus the site seems to load completely new (favicon turns to loader), which of course doesn't happen when using default next. Is this meant to be? I also strangely get an error that the query is missing its input. In the screenshot you can see my getStaticProps and the error. When debugging the getStaticProps, I noticed that this error comes before my access to the query at line 20. ...