tRPC v11 mergeRouters no longer merges middleware stacks automatically
0 reputation · 06 Dec 2025, 20:42 UTC
After upgrading to v11, developers using the mergeRouters helper notice that middleware previously applied to individual routers is no longer present in the combined router. In v10 the helper automatically merged middleware stacks, but the v11 release notes indicate this behavior was removed to give more explicit control. The exact implications for existing codebases that relied on the implicit merging are not fully documented, leaving uncertainty about whether a configuration flag exists to restore the old behavior or if manual re‑application is required for each middleware.
What is the recommended approach to ensure middleware is correctly applied after using mergeRouters in tRPC v11? Is there a way to revert to the automatic merging behavior, or must developers manually re‑attach middleware to the merged router? Does this change affect all middleware types equally, or are certain kinds (e.g., error‑handling middleware) treated differently?