What problem does it solve?
This Skill documents an opinionated, reliable way to initialize and structure a typed tRPC server to avoid type mismatches, accidental server bundling into client code, and runtime errors when merging routers or configuring context.
Core Features & Use Cases
- Single shared t instance: Create initTRPC once and reuse t.router and t.procedure to prevent cross-instance type mismatches.
- Typed context patterns: Implement inner/outer context splits to make server-side testing simple and avoid leaking HTTP objects into tests.
- Router composition & lazy loading: Merge child routers safely with consistent transformers and support lazy-loaded routers to reduce cold-start cost in serverless deployments.
- Common mistakes to avoid: Guidance on reserved procedure names, exporting AppRouter as a type-only import, and ensuring transformer consistency when merging routers.
Quick Start
Initialize a minimal tRPC server using a single initTRPC instance, export router and publicProcedure, create typed context with an inner factory, and merge child routers into an AppRouter.