Build a typed API in 10 minutes with tRPC — no codegen, no schemas
3 months ago
This is The Manual. One library, its own documentation, one sitting. Today, T R P C. By the end you will have a typed A P I running, and every step comes straight from the official docs, which stay on screen the whole time.
Ask about this presentation
Chapters
Show transcriptHide transcript
This is The Manual. One library, its own documentation, one sitting. Today, T R P C. By the end you will have a typed A P I running, and every step comes straight from the official docs, which stay on screen the whole time.
Here is why T R P C is shaped the way it is. Most stacks keep the A P I contract somewhere in the middle, a schema file, generated code, something you have to regenerate. T R P C deletes the middle. Your server exports one TypeScript type, your client imports it, and the compiler does the rest. That is also why the docs ask for TypeScript five point seven or newer, with strict mode on. The types are the product. Five steps. Install, router, procedure, serve, and the typed client. Let's go.
Step one. The quickstart asks for two packages, the server package and the client package. The docs run n p m. We run bun, and we add zod while we are here, because step three will validate inputs with it. Watch the install land. That is the whole footprint. No code generator, no build step, nothing to keep in sync.
Step two, and the first rule the manual states outright. You initialize T R P C exactly once per application. More than one instance causes real trouble, so this file exists to be imported everywhere else. Create the instance. Then export just the pieces you will use, the router helper and a public procedure. The docs are explicit about why. You export methods of t, never t itself, so the whole codebase speaks one idiom.
Step three is where the shape pays off. A procedure named user by I D takes an input parser, a zod schema, and T R P C validates every call before your code runs. The query gets the parsed input, already typed as a string, and returns a user. And then the load bearing line of the entire library. You export the type of the router. The type, not the router. The client will import only this, so no server code ever leaks into the browser bundle.
Step four. The standalone adapter wraps your router in a plain node H T T P server. Listen on a port. That is genuinely the whole server. Adapters exist for express, fastify, next, and the edge runtimes, and the router code never changes. Run it, and the first request streams back.
Step five, the payoff. Import the type. Note the word type in that import, it means the server code itself never ships to the browser. Hand it to the client constructor with a batching link. And now the call site is fully typed. The input must be a string, the result is a user object, and if the server renames a field, this line turns red before you ever run it. The docs put it plainly. Type t r p c dot u, and your whole A P I surfaces in autocomplete.
Before you ship this, three walls people actually hit, straight from the issue tracker. One. Very large routers can break declaration builds. TypeScript refuses to serialize the inferred type once it gets enormous. Annotate the router type or split your libraries. Two. Your dates arrive as strings, because JSON has no date type. Wire a transformer like superjson on both the server and the client, or every timestamp quietly degrades. Three. A loose T S config quietly kills inference. Strict mode is not a style preference here, it is load bearing.
That is the whole A P I. Three small files, one exported type, and a client that refuses to compile when the server changes underneath it. The full runnable snippet ships with this episode, so you can paste it and go. Next in the series, context and middleware, which is where auth lives. The Manual. Read so you don't have to wander.
Up next
6:49AI SDK 7 Output.object returns a typed object or throws
@the-manual
2 months ago
6:49AI SDK 7 streamText calls a typed weather tool
@the-manual
2 months ago
5:22AI SDK 7 streams a terminal response with streamText
@the-manual
2 months ago
5:13Bun.cron schedules a TypeScript job without node-cron
@the-manual
2 months ago
5:56Drizzle leftJoin returns nullable pet rows
@the-manual
2 months ago
6:51Drizzle returns nested posts from one findMany call
@the-manual
2 months ago
6:59Bun SQLite printed Ada and Grace from a file next to the code
@the-manual
2 months ago
6:58Drizzle schema file to first applied migration
@the-manual
2 months ago
7:07Bun 1.4 — install to a running HTTP server
@the-manual
3 months ago








