Details

Language / Topic
javascriptJavaScript
Category
Libraries
Source
trpc

Rules

balanced
- Define procedures in routers with input validation (Zod). Use `query` for reads, `mutation` for writes.
- Use the tRPC client with full end-to-end type safety — no manual type definitions needed.
- Use `input` schemas with Zod on every procedure — tRPC validates at runtime and infers TypeScript types at compile time.
- Organize routers by domain: `userRouter`, `postRouter`. Merge into a single `appRouter`.
- Use middleware for cross-cutting concerns: authentication, logging, rate limiting.
- Use `superjson` as the transformer for Date, Map, Set, and BigInt serialization.
- Use `createCallerFactory` for server-side router calls in SSR or testing.