Guide · Open source
How to use tRPC: typed APIs in TypeScript without schemas
Updated · written with AI from the project's own documentation and checked against our catalogue data
tRPC is an open-source TypeScript library for building and calling APIs where the client gets full type checking and autocompletion from the server's code. It is aimed at developers whose frontend and backend are both written in TypeScript. This guide explains what tRPC does, how to start a project from the README's example, and when it fits your project.
Quick start
- 1Check prerequisites. Install Node.js and choose a package manager such as npm, yarn, pnpm or bun.
- 2Create the starter project. Run the create-next-app command from the README with the tRPC next-prisma-starter example.
- 3Open the project. Move into the new trpc-prisma-starter folder created by the command.
- 4Read the documentation. Follow the full guide on tRPC.io to understand routers and client calls.
- 5Define your server procedures. Write the API functions on the server, following the example app's structure.
- 6Call them from the client. Use the typed client; your editor will autocomplete inputs and outputs.
What tRPC does and how it works
tRPC lets you build and consume fully typesafe APIs without separate schemas or a code generation step. According to the README, the client imports only type declarations from the server, not the server code itself.
The project lists full static type safety and autocompletion on the client for inputs, outputs and errors. It also says it has zero dependencies and a tiny client-side footprint.
- No code generation, run-time bloat or build pipeline, according to the README
- Request batching: requests made at the same time can be combined into one
- Subscriptions support
- Adapters for React.js, Next.js, Express.js and Fastify
Install tRPC with a starter project
The README's quick start uses the full-stack Next.js example in the tRPC repository. You need Node.js and a package manager such as npm, yarn, pnpm or bun.
Run the command for your package manager. The npm version is shown below. The README also lists yarn, pnpm, bun and deno variants.
- Prerequisites: Node.js and a package manager (npm, yarn, pnpm or bun)
- Full documentation is on tRPC.io
npx create-next-app --example https://github.com/trpc/trpc --example-path examples/next-prisma-starter trpc-prisma-starterAdd typed APIs to an existing project
The README says tRPC is easy to add to brownfield projects, meaning existing codebases. The adapters it names are React, Next.js, Express and Fastify.
The README notes that tRPC is not tied to React and that community adapters exist for other libraries. Check the tRPC documentation for the exact setup steps for your framework, since the README does not walk through them.
Use AI coding agents with tRPC
The README suggests installing tRPC skills for AI coding agents such as Claude Code, Cursor or Windsurf, to improve generated code. It gives this command.
npx @tanstack/intent@latest installWhen tRPC is a good fit and when it is not
tRPC suits TypeScript teams building a web app where frontend and backend share TypeScript. Its main benefit is shared types, so it is less useful if your clients are not TypeScript.
For a public API used by third parties in any language, the README does not discuss it, and a standard such as OpenAPI is usually expected. GraphQL, Zod-based RPC libraries and OpenAPI-based tooling are comparable options.
- Good fit: TypeScript frontend and backend, Next.js or React apps, adding types to an existing project
- Consider alternatives: non-TypeScript clients, public third-party APIs needing a language-neutral spec
What people use it for
- Building a full-stack Next.js app with typed calls between client and server
- Adding typed APIs to an existing TypeScript project
- Creating React frontends that call a TypeScript backend without generated clients
- Building real-time features with subscriptions
Frequently asked questions
Is tRPC free to use?
tRPC is released under the MIT licence, as stated in the repository. Check the LICENSE file in the repo for the full terms.
What do I need to run tRPC?
The README lists Node.js and a package manager such as npm, yarn, pnpm or bun. The main benefit depends on writing both client and server in TypeScript.
How do I install tRPC?
The README's quick start uses create-next-app with the full-stack Next.js example from the tRPC repository. Choose the command for your package manager.
Does tRPC only work with React?
No. The README says tRPC is not tied to React and includes adapters for Next.js, Express and Fastify, with community adapters for other libraries.
Do I need a schema or code generation with tRPC?
No. The README says tRPC works without schemas or code generation, and the client imports only type declarations from the server.
What are alternatives to tRPC?
Comparable projects include GraphQL, Zod-based RPC libraries and OpenAPI-based tooling. OpenAPI is usually better for public APIs used by non-TypeScript clients.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
tRPC is a good choice for TypeScript teams that want typed calls between a web frontend and backend without maintaining schemas. If your clients are not TypeScript or you need a language-neutral public API, consider GraphQL or OpenAPI-based tooling instead.
Install options & downloads