Skip to content

Let's compare Redux Toolkit and Zustand in Next.js 14 using basic counter as of July 2024.

Notifications You must be signed in to change notification settings

kenfj/redux-vs-zustand-2024

Repository files navigation

Redux VS Zustand in Next.js 2024

Getting Started

npm ci
npm run dev

# with port number
npm run dev -- -p 3030

Open http://localhost:3000

Comparison

Redux Zustand Winner
setup package official doc is not clear what's required.
you will need react-redux
as well as @reduxjs/toolkit
just zustand Zustand
coding experience official doc is not so friendly
so you will need to google a lot
official doc provides clear info Zustand
readability still mysterious boilerplate required
even in Redux Toolkit
cf. src/redux-lib/hooks.ts
you just need one interface
and useStore custom hook
Zustand
number of lines 38 lines
cf. counterSlice.ts
7 lines
cf. useCounterStore.ts
Zustand
impression always come with dispatch looks not DRY nowadays
need to wrap children by <StoreProvider>
in root layout.tsx almost like Context
optional to use a Context as in CounterStoreProvider.tsx Zustand

Notes

Conclusion

  • Overall, Zustand is much simpler to create basic stuff like counter.
  • if it's more than counter, you may need to consider other factors.

Setup Notes

Next.js

Redux

Zustand

NextUI

Tailwind CSS Typography plugin

Import Sort

Reference

About

Let's compare Redux Toolkit and Zustand in Next.js 14 using basic counter as of July 2024.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published