What is tRPC? #typescript

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

I once had experience working on a project that used tRPC to connect between the frontend and backend. Actually like you said, it's very useful in product development.

K.Huynh.
Автор

From the tRPC official docs: “No, a monorepo is not mandatory but you will lose some of the benefits of using tRPC if you don't use it since you will lose guarantees that your client and server works together.

One way you can leverage tRPC is to publish a private npm package with the types of your backend repo and consume them in your frontend repo.”

So while I don’t agree with the first statement (you have to have it in the same repo) I do agree with the second statement (you might be better off using GraphQL)

yamyam
Автор

Protobuf + grpc also works for creating schema contracts between front and back.

AshleyWilsonAU
Автор

Recently used Zodios for creating type safe client for the frontend and router for the backed. Also it generates OpenAPI. There are some DX performance issues, but hopefully the maintainer will figure it out soon.

totetoBT
Автор

I can already see they're using zod to validate the types... I'm really used to rest and have made my own WS-based protocol for file syncing to know some more but maybe tRPC is gonna get me to transition some projects...

shapelessed
Автор

You can get 90+% the experience with a non-TS backend too.
Just generate your TS client from your backend’s OpenAPI spec

kabal
Автор

Like you say, when it works. I had hard times to update react-query (v3 to v4) because tRPC at a time had lower version needed, and update on tRPC was not so easy, like Angular2 release. I liked an idea, it's great, really, but it reminds me more of message events rather then real api. When you are familiar with typescript enough, it's better to not use this one and do your own instead, based on same principles, because it's not hard to implement on top of REST, but you keep your own update cycle.

belkamax
Автор

Back-end and front end are usually deployed at different times even if the deployment process starts at the same time. The backend would have to be backwards compatible even though the dev experience might give one a feeling that it doesn't have to be. 🤔

ahmadnraja
Автор

tRPC is great but ts-rest is also incredible. Give it a look!

MattChinander
Автор

"only in the same repo".. ahh, you lost me now, .. sorry.

ColinRichardson
Автор

trpc can also call methods through http protocol if you would like to use it in other platform e.g. react native and nextjs app could have same API source

RegalWK
Автор

It doesn't have to be in the same repo if you use git submodules.

mettle_x
Автор

But you need validation on frontend anyway, no?

Fmwins
Автор

trpc is one of the most garbage thing that ive ever worked with

mahdiuserp
Автор

This is where next.js’s app router is game changing. ❤

BlurryBit