trpc-type-safety

Define tRPC routers with Zod validation for end-to-end TypeScript type safety.

Updated May 7, 2026
One-click install
npx skills add https://github.com/johinsDev/loyalty-app --skill trpc-type-safety-johinsdev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: trpc-type-safety
Source: https://github.com/johinsDev/loyalty-app/tree/main/.claude/skills/trpc
Command: npx skills add https://github.com/johinsDev/loyalty-app --skill trpc-type-safety-johinsdev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the problem of losing type safety between client and server by ensuring that API contracts are defined once and enforced end-to-end in TypeScript.

Core Features & Use Cases

  • Type-safe router and procedures: Define queries and mutations whose inputs/outputs are validated and inferred automatically.
  • Zod-powered validation: Guarantee runtime correctness while preserving compile-time TypeScript types.
  • React Query integration: Use caching, retries, and invalidation with full end-to-end typing.
  • Next.js integration patterns: Wire tRPC into App Router, including server usage and request handlers.
  • Real-time subscriptions + file upload patterns: Add subscription-based updates and safe upload flows via signed URLs.

Quick Start

Use the trpc-type-safety skill to implement an end-to-end typed API by defining a tRPC router on the server with Zod input validation and then calling it from a React component with the generated React Query hooks.

Frequently Asked Questions about trpc-type-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build fully type-safe tRPC APIs in a full-stack TypeScript application?

To build fully type-safe tRPC APIs, define tRPC routers and procedures on the server with Zod input validation, then call them from a React client using generated hooks. This shares types across server and client, ensuring your TypeScript API contracts are enforced end-to-end without manual type synchronization.

How do I set up tRPC with Next.js App Router while maintaining end-to-end types?

Setting up tRPC with Next.js App Router involves wiring tRPC into server usage and request handlers using App Router adapters. This integration maintains end-to-end TypeScript type safety by automatically inferring input and output types across your server components and client-side React Query hooks.

Can I use React Query caching and mutations with tRPC procedures?

Yes, you can use React Query caching, retries, and invalidation with tRPC procedures while maintaining full end-to-end typing. The integration generates typed hooks that automatically infer query and mutation signatures, preserving compile-time TypeScript safety across your client-side data fetching logic.

Does tRPC type safety support real-time subscriptions and file upload flows?

tRPC type safety supports subscription-based real-time updates and safe file upload flows via signed URLs. You can define typed procedures that handle subscription-based updates and upload flows, ensuring that real-time data and file payloads maintain strict end-to-end TypeScript inference.

Why should I use Zod validation in tRPC procedures for runtime and compile-time safety?

Using Zod validation in tRPC procedures guarantees runtime correctness while preserving compile-time TypeScript types. Zod schemas validate incoming request data against defined rules and automatically infer TypeScript types, bridging the gap between server validation and client-side type inference.

What is the best way to share API contracts between client and server in TypeScript?

The best way to share API contracts between client and server in TypeScript is using tRPC to define queries and mutations whose inputs and outputs are validated and inferred automatically. This enforces API contracts end-to-end by defining them once on the server, eliminating manual interface duplication.