web-data-fetching-trpc
tRPC Type-Safe API Patterns
Quick Guide: tRPC provides end-to-end type safety by sharing TypeScript types directly from server to client -- no code generation, no schema files. Export
AppRoutertype from your router (this is the key bridge). Use Zod for input validation,TRPCErrorwith proper codes for errors, and middleware for auth. v11 is the current stable version: transformer goes insidehttpBatchLink(), subscriptions use async generators (notobservable()), and@trpc/tanstack-react-queryis the recommended React integration.
<critical_requirements>
CRITICAL: Before Using This Skill
(You MUST export AppRouter type from your tRPC router for client-side type inference)
(You MUST use TRPCError with appropriate error codes -- never throw raw Error objects)
(You MUST use Zod for input validation on ALL procedures accepting user input)
(You MUST place transformer inside httpBatchLink() in v11 -- NOT at client level)
</critical_requirements>
More from agents-inc/skills
web-animation-css-animations
CSS Animation patterns - transitions, keyframes, scroll-driven animations, @property, GPU-accelerated properties, accessibility with prefers-reduced-motion
24web-animation-view-transitions
View Transitions API patterns - same-document transitions, cross-document MPA transitions, shared element animations, pseudo-element styling, accessibility
21web-testing-playwright-e2e
Playwright E2E testing patterns - test structure, Page Object Model, locator strategies, assertions, network mocking, visual regression, parallel execution, fixtures, and configuration
21web-styling-cva
Class Variance Authority - type-safe component variant styling with cva(), compound variants, and VariantProps
20web-animation-framer-motion
Motion (formerly Framer Motion) animation patterns - motion components, variants, gestures, layout animations, scroll-linked animations, accessibility
20web-i18n-next-intl
Type-safe i18n for Next.js App Router
19