tRPC v10 Router Architecture: Modularizing Server Instance and Router Definitions
0 reputation · 23 Mar 2023, 08:24 UTC
Transitioning to Modular Router Definitions
The shift from tRPC v9 to v10 introduced a redesigned API architecture that decouples the router definition from the server instance. This change is intended to improve tree-shaking and allow for a more granular TypeScript-first approach to API definitions.
When implementing complex nested routers, there is a design trade-off between maintaining strict type-safety across the entire API surface and the flexibility required for dynamic routing patterns. Ensuring that the @trpc/server package maintains type integrity during this separation requires precise generic definitions.
- How does the separation of the router and server instance affect the propagation of TypeScript generics in deeply nested router structures?
- What are the implications for tree-shaking when shared procedure middleware is applied across multiple decoupled routers?