pkgdocs/compare/dayjs vs immer

Comparing

npm

dayjs

2KB immutable date time library alternative to Moment.js with the same modern API

43.9M/ wk
v1.11.20
vs
npm

immer

Create your next immutable state by mutating the current one

41.7M/ wk
v11.1.4
Metricdayjsimmer
Ecosystemnpmnpm
DifficultyIntermediateBeginner ✓
Weekly downloads43.9M↑41.7M
Latest versionv1.11.20v11.1.4
Recipes11

Tags

dayjs only

datetimemomentformattingdayjsdate-formattingdatetime

Shared

immutabletypescript

immer only

statereduxreactmutationsmutablecopy-on-writeimmutablesreducer

When to use each

dayjs

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.

immer

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.

When to skip each

dayjs

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.

immer

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().

Sample recipes

dayjs

  • Install dayjs

immer

  • Install immer