Eliminating API Drift with tRPC Router Type Exports
tRPC achieves end-to-end type safety by exporting server router types. This eliminates manual schema synchronization and prevents runtime API drift.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
tRPC achieves end-to-end type safety by exporting server router types. This eliminates manual schema synchronization and prevents runtime API drift.
A technical guide on choosing between Offset and Cursor pagination in tRPC, featuring performance comparisons and a production-ready implementation for stable data fetching.
Stop fighting API drift. Learn how tRPC uses TypeScript type inference and Zod to create a zero-codegen, end-to-end type-safe contract between your server and client.
Learn how to diagnose and fix HTTP 400 BAD_REQUEST errors in tRPC caused by Zod schema mismatches between the client payload and server expectations.
tRPC's real payoff isn't "types" — it's deleting the duplicated contract between server and client. Here's the worked example, the rename test that proves it, and where it falls down.
Learn how to implement tRPC procedures to eliminate type drift between your TypeScript server and client using Zod validation and middleware.
Middleware Execution Order In tRPC v10 and later, middlewares run before the built‑in input validation step. This means a middleware receives raw, unvalidated data and can act on it before the framework checks types or constraints. Developers often rely on middleware for authentication, logging, or request shaping, assuming that the data it receives has alre
Error code propagation inconsistency When a server procedure throws a TRPCError with code NOT_FOUND , the client receives an error object whose shape reflects the mapped HTTP status. However, the inferred type from the shared AppRouter does not appear to constrain the possible error codes per procedure, allowing the client to handle only a subset of codes at
When using tRPC's httpBatchLink with the default 1 ms batchWindow, request latency remains low for isolated calls but shows a noticeable increase in the 95th‑plus percentile as concurrent request volume rises. The batchWindow is a fixed timer that does not adapt to request arrival patterns, and any synchronous work in middleware or context creation can delay