Basically: - What the fuck is this? - Do I need this? - Why is it better? - How do I use this?
11 months ago | 14
Absolutely love the library. For people who are asking why TRPC or for whoever is curious : 1 - Type safety all the way! From the back-end to the front-end, TRPC nails it. 2 - MIDDLEWARES. It’s fantastic how it supports running typical “middleware” tasks like dependency injection, but what really stands out is how you can narrow types and pipe them down to both procedures/endpoints and other middlewares! Extending middlewares such a great feature, especially with the type narrowing you get through this chef’s kiss. (I worked on a project with lots of roles/permissions, and reusable and extendable middlewares were a life saver.) 3 - The flexibility to switch between a server-side caller (for RSC), a client-side caller, or a useQuery/useSuspenseQuery hook (with optional server-side prefetching). 4 - This is for the React Query fans, this library is a really good query key manager. If the routers are well structured, query invalidations can be finely tuned easily. 5 - Zod validators for both inputs and outputs. 6 - The ability to modify the request-type (GET/POST), optional streaming, and optional batching. There are many other great features I haven’t mentioned, like websockets and subscriptions. There are few issues that I did run into though. 1 - The very first time while setting it up, can feel a bit overwhelming. 2 - I’m not entirely sure, but I believe the backend procedures aren’t lazy loaded by default. I’m not sure how big of a performance impact this has, would love some insights on this. 3 - A NextJS specific one here, it would’ve been great if redirects were possible, similar to redirects within route handlers. 4 - The TS server performance did take a hit in a larger project. I took your suggestion from the TS performance video, to explicitly mention the function return types. I tried everything I could think of, nothing worked, not even annotating a variable and returning it helped, nope, it had to be the return type of the function. The speed gains were significant, but that’s now another export to be maintained. I’m curious about how and why this even works the way it does.
11 months ago (edited) | 2
I love TRPC. End to end type safety is a game changer. The problem I got with TRPC is that it frustrated me how to handle file upload and I have to stick with hono router. The second is that benchmarks show that Deno and Bun web socket were faster than ws, but there's no good resources to reference to use Bun and Deno's web socket for subscription.
11 months ago | 1
I'm not sure why it's necessary to use tRPC in a Next.js application where you can already fetch data from the database (using Drizzle or Prisma) and make server actions type-safe. What's the added benefit of using tRPC in this case?
11 months ago | 8
How to use tRPC transfer data type Date or File practically? Should we use effect/schema instead of zod? Show me your prefer directory structure please.
11 months ago | 2
Explanation of how it works on a low level: what does the routes it creates look like, inspect it using the network tab etc.
11 months ago | 0
How do they optimize TS language server performance with this amount of inference going on?
11 months ago | 8
why is trpc a good idea? I Introduced it into a project recently and immediately regretted it, it tries to be too magical. it's not like zod where it actually does something, you're just defining a const object with your API routes, transforming the type into that of the client API and then importing that type on the client. I wrote my own trpc style tranformer, took maybe 20 lines of ts and now I actually have control over my API again.
11 months ago | 1
What is the best way to use trpc with client and server being separate projects (not like in NextJS or Remix)?
11 months ago | 4
tRPC has some advanced features like streaming data. I've tried it once and it's kinda like websockets, but without the hassle of setting up another server/wss support. Would love to see some real world examples where streaming data to a website would actually help, and how to handle the UI/typescript types for data that could be still streaming in.
11 months ago | 0
I love using tRPC. One thing I’ve been pondering is re-usability. The nice thing about working with something like GraphQL is that your queries and mutations can be used by any sort of client these days. This is not the case with tRPC of course, being locked to a TS environment. Thus, the value of building a more standard API seems to be higher. Curious of your thoughts on this.
11 months ago (edited) | 0
Can you talk about how testing works with it. For instance with MSW and how the traffic actually looks over the wire compared to REST.
11 months ago | 0
What is the best way to call trpc endpoints from clients like Postman?
11 months ago | 0
Matt Pocock
What questions do you have about tRPC?
Any level. Hit me with them:
- Why you'd use it
- Advanced use cases
- tRPC vs X vs X
11 months ago | [YT] | 61