Search

Search pages, services, tech stack, and blog posts

tRPC

tRPC BackendEnd-to-end typesafe APIs without code generation

tRPC lets your frontend call server functions directly with full TypeScript type safety — no REST contracts, no GraphQL schemas, no code generation. If your server types change, your editor tells you instantly.

tRPC enables end-to-end type safety between your TypeScript backend and frontend without code generation, REST contracts, or GraphQL schemas. Change a server function's return type and your editor instantly shows every affected client call. At A Major, we use tRPC for full-stack TypeScript applications where developer velocity and type safety are equally critical. tRPC integrates seamlessly with React Query for caching, refetching, and optimistic updates. Combined with Zod for input validation and Next.js for server-side rendering, tRPC creates a development experience where the entire stack is a single type-safe codebase.

Quick start

bash
npx create-t3-app@latest my-app
cd my-app
npm run dev

Read the full documentation at trpc.io/docs

Zero schema duplication

Define your API contract once — TypeScript infers input and output types on both client and server automatically.

React Query integration

First-class TanStack Query hooks — typed queries, mutations, and infinite scroll with automatic cache invalidation.

Zod input validation

Runtime validation and TypeScript types from the same Zod schema — one source of truth for your API inputs.

Middleware & context

Composable middleware chain for auth, logging, and rate limiting with typed context passed to every procedure.

Any backend runtime

Works with Next.js, Express, Fastify, or any Node-compatible server — bring your own HTTP layer.

Server-side calls

Call tRPC procedures directly on the server without HTTP overhead — ideal for RSC and server actions.

Why it's hard

TypeScript-only ecosystem

tRPC requires TypeScript on both server and client. If you need to support non-TypeScript consumers (mobile apps, third-party integrations), you need a REST or GraphQL layer alongside tRPC.

No OpenAPI spec generation

tRPC doesn't generate OpenAPI docs natively. For public APIs consumed by external partners, consider oRPC or a dedicated REST layer.

Monorepo coupling

tRPC type inference works best in monorepos where server and client share the same TypeScript project. Separate repos lose the type-safety advantage.

Best practices

Organize routers by domain feature

Create separate router files per domain (userRouter, postRouter) and merge them into a single appRouter.

Use Zod for all input validation

Zod schemas validate input at runtime and provide TypeScript types at compile time — single source of truth for your API contract.

Leverage React Query's caching

tRPC wraps React Query — use staleTime, gcTime, and invalidation patterns to minimize unnecessary refetches.

Use middleware for auth and logging

tRPC middleware runs before procedures — centralize authentication, authorization, and request logging in reusable middleware.

Frequently asked questions




Want to build with tRPC?

Talk to our engineering team about your tRPC architecture. We'll respond within 24 hours.

1 spot available in May 2026Apr 2026 fully booked

We limit intake each month so every project gets the focus it deserves.