tRPC
ELI5 — The Vibe Check
tRPC lets you call your backend functions directly from the frontend with full TypeScript type safety — no REST endpoints, no API schema, no code generation. Define a function on the server, and TypeScript knows exactly what you can call and what it returns on the client. Change the backend? The frontend gets red squiggles instantly. It's like your backend and frontend share one brain.
Real Talk
tRPC is a TypeScript framework that enables end-to-end type-safe APIs without code generation or runtime schemas. The server defines procedures (queries, mutations, subscriptions) using TypeScript, and the client infers types directly from the server code through TypeScript's type system. It works with any framework (Next.js, Nuxt, Express) and eliminates the API contract layer (no OpenAPI, no GraphQL schema). Best suited for full-stack TypeScript monorepos.
Show Me The Code
// Server
const appRouter = router({
getUser: publicProcedure
.input(z.object({ id: z.string() }))
.query(async ({ input }) => {
return db.user.findUnique({ where: { id: input.id } });
}),
});
// Client — fully typed, no codegen!
const user = await trpc.getUser.query({ id: '123' });
console.log(user.name); // TypeScript knows the shape!
When You'll Hear This
"Use tRPC — we're already full-stack TypeScript, so why maintain a REST API?" / "tRPC eliminates the 'did I update the API types?' problem."
Related Terms
API (Application Programming Interface)
An API is like a menu at a restaurant. The kitchen (server) can do a bunch of things, but you can only order what's on the menu.
GraphQL
GraphQL is like ordering food where YOU specify exactly what you want on your plate.
REST (Representational State Transfer)
REST is a set of rules for how APIs should behave. Think of it as the etiquette guide for servers and clients talking to each other.
TypeScript
TypeScript is JavaScript with a strict parent watching over it.