Menu

1 / 4

Building a tRPC Router from First Principles

DEV Community·Gabriel Anhaia·6 months ago
#54rofJ8I
#releasedin2025#trick#building#type#router
Reading 0:00
15s threshold

Book: TypeScript in Production — Tooling, Build, and Library Authoring Across Runtimes

Also by me: The TypeScript Library — the 5-book collection

My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools

Me: xgabriel.com | GitHub

You add a greet route on the server that takes { name: string } and returns a string. After saving, you flip to the client tab and start typing client.greet.query({ , and autocomplete already shows name . Type a wrong value, the squiggle fires before you finish. Nothing was generated, no OpenAPI document was rebuilt, no watcher kicked in. The server route is plain TypeScript, the client is plain TypeScript, they talk over JSON. How does tRPC do that?

The answer is two type-system tricks and a transport. Once you see them, both tricks look small.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.