gRPC vs tRPC
People think tRPC is gRPC for TypeScript, and it is not. gRPC sends small binary messages between services written in many languages. tRPC sends JSON, and it only works when both ends are TypeScript and share the same types. The names differ by one letter, and the jobs differ a lot.
gRPC
A fast way for one service to call another. Its messages are small.
gRPC is a fast way for services to call each other's functions. Google made it and opened it to everyone in 2015. You describe each service and its messages in a .proto file. Tools turn that file into ready code for many languages. Messages are sent in a small binary format called Protocol Buffers, over HTTP/2. It is fast and strict, so firms use it between their own services.
tRPC
A TypeScript tool. The front end calls server code, and both share the same types.
tRPC is a TypeScript tool for building APIs where the front end and back end share types. You write a function on the server. The front end calls it as if it were a local function. If the server changes, the front end shows a type error at once. It needs no schema file and no generated code, but both sides must use TypeScript.
In one line
- gRPC
- A fast way for one service to call another. Its messages are small.
- tRPC
- A TypeScript tool. The front end calls server code, and both share the same types.