DEV Community

Marc Daddy
Marc Daddy

Posted on

What is tRPC?

If you've ever wanted a fully typesafe API without having to deal with the complexity of the traditional data query and manipulation language for APIs such as GraphQL (developed by Facebook in 2012), REST etc. you may want to try tRPC. tRCP combines the ideas of classic REST APIs with GraphQL to form a new way of transfering data from the server to the client and vice versa, this essentially allows you to call functions on clients doing API calls behind the scene. The calls are fully typesafe and end to end.

Image description

tRPC is for full-stack typescripters, it is designed for monorepos as you need to export/import the type definition from/to your server. If you have a custom GraphQL-server for your project, you may want to use tRPC. It makes it dead easy to write "endpoints" which you safely use in your app.

tRCP is library agnostic so it could be used with any front-end framework been utilised. Below are some of the features of tRPC:

  • Full static typesafety & autocompletion on the client, for inputs and errors
  • Light - tRPC has zero deps and a tiny client-side footprint
  • Snappy DX - No code generation, run-time bloat, or build pipeline
  • Easy to add to your existing brownfield project
  • Request batching - requests made at the same time can be automatically combined into one

tRPC also include a lot of other things like the option to add middlewares, request context, merge routers, batching of your queries, error handling, data transformer etc. If you are interested in typesafety from server to client in your APIs or GraphQL is not for you, check out tRPC at https://trpc.io

Top comments (0)