DEV Community

Alex Spinov
Alex Spinov

Posted on

tRPC Has a Free End-to-End Type Safety — Build APIs Without REST or GraphQL Boilerplate

A full-stack developer maintained separate TypeScript types for the frontend API client and the backend routes. Every API change required updates in two places. Types drifted. Bugs followed.

tRPC is a free framework that gives you end-to-end type safety. Change a backend function, your frontend gets type errors instantly. No code generation, no schemas.

What tRPC Offers for Free

  • End-to-End Types - Backend types flow to frontend automatically
  • No Code Generation - Types are inferred, not generated
  • No REST/GraphQL - Direct function calls with full type safety
  • Subscriptions - Real-time via WebSocket
  • Middleware - Auth, logging, rate limiting
  • Batching - Multiple requests in one HTTP call
  • React Query - Built-in React Query integration
  • Next.js - First-class Next.js support

Quick Start

// server
const appRouter = router({
  getUser: publicProcedure
    .input(z.object({ id: z.string() }))
    .query(({ input }) => {
      return db.user.findUnique({ where: { id: input.id } })
    }),
})

// client - fully typed, auto-complete works
const user = await trpc.getUser.query({ id: '1' })
Enter fullscreen mode Exit fullscreen mode

GitHub: trpc/trpc - 35K+ stars


Need to monitor and scrape data from multiple web services automatically? I build custom scraping solutions. Check out my web scraping toolkit or email me at spinov001@gmail.com for a tailored solution.

Top comments (0)