End-to-End Type-Safe APIs for NestJS
The missing bridge between NestJS and tRPC. Decorators you already know, types that write themselves, powered by a Rust CLI that generates in milliseconds.

The client above is not importing any code from the server, only its type declarations.
Why NestJS tRPC?
Everything you need to build type-safe APIs in NestJS.
End-to-End Type Safety
Full static typesafety and autocompletion for inputs, outputs, and errors — from server to client. Zero runtime overhead.
Rust-Powered CLI
Type generation in milliseconds, not seconds. 10-50x faster than TypeScript-based tools with rich error messages.
NestJS Dependency Injection
Routers, middlewares, and error handlers are first-class NestJS providers.
Zero Boilerplate
@Router, @Query, @Mutation decorators replace manual router wiring.
Real-Time Subscriptions
Stream data with SSE using async generators on tRPC v11.
Express & Fastify
Auto-detected HTTP adapter. Works out of the box with both.
Typed Middlewares & Context
Global and per-route middlewares with full DI support and auto-typed context.
Watch Mode
Automatic type regeneration during development.
Get Started in 3 Steps
From install to type-safe client in under 5 minutes.
Install & Configure
Add nestjs-trpc to your NestJS app and configure the module with your preferred settings.
import { Module } from '@nestjs/common';import { TRPCModule } from 'nestjs-trpc';@Module({imports: [TRPCModule.forRoot(),],})export class AppModule {}
Define Your Router
Use familiar NestJS decorators with full dependency injection and Zod schema validation.
import { Router, Query } from 'nestjs-trpc';import { Inject } from '@nestjs/common';import { z } from 'zod';import { UserService } from './user.service';@Router({ alias: 'users' })export class UserRouter {constructor(@Inject(UserService)private readonly userService: UserService,) {}@Query({input: z.object({ id: z.string() }),output: z.object({id: z.string(),name: z.string(),}),})getUserById(input: { id: string }) {return this.userService.findById(input.id);}}
Generate & Consume
Run the CLI to generate types, then enjoy full autocompletion on the client.
// Run: npx nestjs-trpc generate// Client-side usage with full type safetyimport { createTRPCClient } from '@trpc/client';import type { AppRouter } from './server/@generated';const client = createTRPCClient<AppRouter>({links: [/* ... */],});// Full autocompletion & type checkingconst user = await client.users.getUserById.query({id: '1',});// ^? { id: string; name: string }
Built for the NestJS Ecosystem
NestJS tRPC works the way you'd expect a NestJS library to work.
Without NestJS tRPC
Manual router wiring with nested function calls
With NestJS tRPC
Declarative @Router, @Query, @Mutation decorators
Without NestJS tRPC
Separate dependency injection system or none at all
With NestJS tRPC
Native NestJS DI — inject services directly into routers
Without NestJS tRPC
Manual type generation scripts or no generation at all
With NestJS tRPC
Rust CLI generates types in milliseconds with watch mode
Frequently Asked Questions
Is NestJS tRPC production-ready?
How does it compare to using tRPC directly?
What versions of tRPC and Zod are supported?
How fast is the type generation CLI?
Can I use this with my existing NestJS project?
Does it support real-time subscriptions?
Community
Join the growing NestJS tRPC community.