trpc-fullstack

Build end-to-end type-safe APIs with tRPC routers, procedures, and Next.js integration.

1|Updated Dec 29, 2025
One-click install
npx skills add https://github.com/ratnesh-maurya/tracker.ratnesh-maurya.com --skill trpc-fullstack-ratnesh-maurya
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: trpc-fullstack
Source: https://github.com/ratnesh-maurya/tracker.ratnesh-maurya.com/tree/main/.claude/skills/trpc-fullstack
Command: npx skills add https://github.com/ratnesh-maurya/tracker.ratnesh-maurya.com --skill trpc-fullstack-ratnesh-maurya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @trpc/server, @trpc/client, @trpc/react-query, @tanstack/react-query, zod.

What problem does it solve? Building APIs in TypeScript full-stack apps often means duplicating types between server and client, writing schemas, or maintaining code generation pipelines. This Skill provides patterns for creating fully type-safe APIs where TypeScript types flow directly from server routers to the client, eliminating schema overhead and making API calls autocompleted and refactoring-safe. ## Core Features & Use Cases - Router and Procedure Patterns: Define queries, mutations, and subscriptions with Zod input validation, auth middleware, and protected procedures. - Next.js App Router Integration: Set up fetch-based handlers, dual context factories for HTTP and Server Components, and React Query client providers. - Real-Time Subscriptions: Implement WebSocket-based subscriptions with observables and EventEmitter for live notifications. - Use Case: You are building a Next.js app and need a posts API. Use this Skill to scaffold a tRPC router with cursor pagination, auth-protected mutations, and a React client with automatic cache invalidation after mutations. ## Quick Start Set up a tRPC router with a protected posts procedure and wire it into my Next.js App Router project with a React Query client.

Frequently Asked Questions about trpc-fullstack

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

FAQPage Schema
How do I set up tRPC with Next.js App Router?▼

Use fetchRequestHandler from @trpc/server/adapters/fetch in a route handler at app/api/trpc/[trpc]/route.ts, exporting it as GET and POST. The App Router requires the fetch adapter because handlers receive a fetch Request, not a Pages Router req/res pair.

How to add authentication to tRPC procedures?▼

Create a middleware that checks ctx.session and throws TRPCError with code UNAUTHORIZED when absent, then build a protectedProcedure with t.procedure.use(enforceAuth). The middleware can extend context to narrow the session type for downstream procedures.

Does tRPC support real-time subscriptions?▼

Yes, tRPC supports subscriptions using observables from @trpc/server/observable, typically backed by an EventEmitter. The client must use splitLink to route subscriptions to wsLink while queries and mutations go through httpBatchLink.

Why is my auth session null in tRPC protected procedures?▼

This happens when the context factory receives a Pages Router req/res cast via as any inside an App Router handler. Ensure createTRPCContext uses server-side auth like auth() from Next-Auth v5 and matches the fetch adapter signature.

Why are tRPC mutations not updating the UI?▼

React Query caches query results, so mutations do not automatically refresh displayed data. Call utils.<router>.<procedure>.invalidate() in the mutation's onSuccess callback to trigger a refetch.

When should I not use tRPC for an API?▼

tRPC requires the client and server to share a TypeScript codebase, so it does not fit public APIs consumed by third parties or polyglot clients. In those cases, REST or GraphQL with an explicit schema is the better choice.