# tRPC

> A TypeScript tool. The front end calls server code, and both share the same types.

**Field:** Software Development  
**Category:** APIs  
**Also known as:** TypeScript Remote Procedure Call, tRPC API, tRPC Router

## Think of it like

Think of it like a phone where both people speak the same language. Nothing gets lost in translation.

## Definition

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.

## Example

Emma renames a field on her server. Her editor at once marks every front-end line that used the old name.

## Example code

```typescript
const order = await trpc.order.byId.query({ id: 42 });
console.log(order.total);
```

The front end calls the server function, and its types come along.

## Why it matters

Mistakes between front end and back end show up while you type, not after you ship.

## Common mistake

Using it for a public API. Outside users may not use TypeScript, so REST or GraphQL fits better.

## Three principles

- **Shared types.** Both sides see the same shapes.
- **No schema file.** The code is the contract.
- **TypeScript only.** Best when one team owns both ends.

## Related terms

- [Remote Procedure Call (RPC)](https://learn.benibix.com/term/development/remote-procedure-call)
- [TypeScript](https://learn.benibix.com/term/development/typescript)
- [REST API](https://learn.benibix.com/term/development/rest-api)
- [GraphQL](https://learn.benibix.com/term/development/graphql)

## Told apart from

- [gRPC vs tRPC](https://learn.benibix.com/compare/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.

![Three ways to send the same GET request to an API. In JavaScript code, Axios. In Python code, Requests. In a terminal, HTTPie with the command http. All three arrows point to one endpoint, which sends back JSON.](https://learn.benibix.com/diagrams/dev3-http-clients.svg)

---

Source: https://learn.benibix.com/term/development/trpc
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
