KevinEdry/nestjs-trpc
KevinEdry/nestjs-trpc has 354 GitHub stars and 37 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-17 03:45 UTC. Last push 2026-11-13.
What you can do
- Fast Rust-based CLI for type generation with rich error messages
- Full static typesafety & autocompletion on the client, for inputs, outputs, and errors
- Implements the NestJS opinionated approach to how tRPC works
- Watch mode for auto-regeneration during development
Measured star growth
- in 24h
- 0
- in 7 days
- Update delayed
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
About
Providing native support for decorators and implement an opinionated approach that aligns with NestJS conventions.
Developer ToolsREADME.md
Original
Nestjs tRPC Adapter
An opinionated approach to building
End-to-end typesafe APIs with tRPC within NestJS.
The client above is not importing any code from the server, only its type declarations.
Introduction
NestJS tRPC is a library designed to integrate the capabilities of tRPC into the NestJS framework. It aims to provide native support for decorators and implement an opinionated approach that aligns with NestJS conventions.
Features
- Fast Rust-based CLI for type generation with rich error messages
- Full static typesafety & autocompletion on the client, for inputs, outputs, and errors
- Implements the NestJS opinionated approach to how tRPC works
- Watch mode for auto-regeneration during development
- Out of the box support for Dependency Injection within the routes and procedures
- Native support for
express,fastify, andzodwith more drivers to come - Examples are available in the ./examples folder
Quickstart
Installation
To install NestJS tRPC with your preferred package manager, you can use any of the following commands:
# bun
bun add nestjs-trpc zod @trpc/server
# npm
npm install nestjs-trpc zod @trpc/server
# pnpm
pnpm add nestjs-trpc zod @trpc/server
# yarn
yarn add nestjs-trpc zod @trpc/server
Generate Types
Run the CLI to generate your AppRouter types:
# Generate types (one-time)
npx nestjs-trpc generate
# Watch mode for development
npx nestjs-trpc watch
How to use
Here's a brief example demonstrating how to use the decorators available in NestJS tRPC:
// users.router.ts
import { Inject } from '@nestjs/common';
import { Router, Query, UseMiddlewares } from 'nestjs-trpc';
import { UserService } from './user.service';
import { ProtectedMiddleware } from './protected.middleware';
import { TRPCError } from '@trpc/server';
import { z } from 'zod';
const userSchema = z.object({
name: z.string(),
password: z.string()
})
@Router()
class UserRouter {
constructor(
@Inject(UserService) private readonly userService: UserService
) {}
@UseMiddlewares(ProtectedMiddleware)
@Query({ output: z.array(userSchema) })
async getUsers() {
try {
return this.userService.getUsers();
} catch (error: unknown) {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: "An error has occured when trying to get users.",
cause: error
})
}
}
}
👉 See full documentation on NestJS-tRPC.io. 👈
All contributors
NestJS tRPC is developed by Kevin Edry, which taken a huge inspiration from both NestJS and tRPC inner workings.