Comparing
2KB immutable date time library alternative to Moment.js with the same modern API
End-to-end type-safe APIs — share TypeScript types between server and client without code generation.
| Metric | dayjs | @trpc/server |
|---|---|---|
| Ecosystem | npm | npm |
| Difficulty | Intermediate ✓ | Advanced |
| Weekly downloads | 43.9M↑ | 1.2M |
| Latest version | v1.11.20 | v11.0.0 |
| Recipes | 1 | 2↑ |
dayjs only
Shared
@trpc/server only
Use Day.js when you need date parsing, formatting, arithmetic (add/subtract days/months), or comparisons in browser code where bundle size matters. Its plugin system covers timezones, relative time ('3 hours ago'), duration, and ISO weeks.
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 complex timezone-aware calendar applications, consider Temporal (the upcoming TC39 proposal) or date-fns with explicit timezone handling. Day.js's plugin system can grow large if you need many features.
Public APIs consumed by third parties (use REST or GraphQL). Polyglot teams where some consumers aren't TypeScript. Microservices with many separate repos.
dayjs
@trpc/server