Comparing
Create your next immutable state by mutating the current one
End-to-end type-safe APIs — share TypeScript types between server and client without code generation.
| Metric | immer | @trpc/server |
|---|---|---|
| Ecosystem | npm | npm |
| Difficulty | Beginner ✓ | Advanced |
| Weekly downloads | 41.7M↑ | 1.2M |
| Latest version | v11.1.4 | v11.0.0 |
| Recipes | 1 | 2↑ |
immer only
Shared
@trpc/server only
Use Immer whenever you have deeply nested state updates that are painful to write immutably: Redux reducers, Zustand's set function, or React useState with complex objects. It's built into Redux Toolkit's createSlice, so you're probably already using it.
Full-stack TypeScript monorepos, Next.js apps where frontend and backend share a codebase, projects where you want type safety without REST/GraphQL ceremony.
For flat, simple state (a counter, a boolean toggle), immer's overhead isn't worth it — just spread the object. Immer also has edge cases with classes, Maps, and Sets that require using enableMapSet() and enableAllPlugins().
Public APIs consumed by third parties (use REST or GraphQL). Polyglot teams where some consumers aren't TypeScript. Microservices with many separate repos.
immer
@trpc/server