Get Advice Icon

Need advice about which tool to choose?Ask the StackShare community!

redux-thunk

754
185
+ 1
6
Zustand

259
152
+ 1
34
Add tool

Zustand vs redux-thunk: What are the differences?

Introduction

In this article, we will explore the key differences between Zustand and redux-thunk. Zustand and redux-thunk are both state management libraries for JavaScript applications, but they have some distinct characteristics that set them apart. Let's dive into the details.

  1. Ease of Use: Zustand is a lightweight state management library that aims to provide a simple and intuitive API for managing application state. It offers a minimalistic approach to state management, making it easy to understand and use. On the other hand, redux-thunk is a middleware for Redux that allows writing asynchronous logic in actions. It requires a more complex setup and understanding of Redux concepts.

  2. Performance: Zustand is designed to be highly performant, thanks to its optimized reactivity engine. It leverages the React hook API, which enables efficient state updates and renders. On the other hand, redux-thunk introduces additional middleware and higher-order functions, which can impact performance in certain scenarios, especially when dealing with a large number of actions or complex asynchronous flows.

  3. Bundle Size: Zustand is known for its small footprint due to its minimalistic design. It weighs only a few kilobytes when gzipped, making it an excellent choice for applications where file size matters. On the other hand, redux-thunk is part of the Redux ecosystem, which adds some overhead to the bundle size. Redux itself is known for having a larger bundle size compared to Zustand.

  4. Middleware Support: Zustand does not natively support middlewares like redux-thunk. However, Zustand provides an extendable API that allows developers to implement custom middleware-like functionality if needed. On the other hand, redux-thunk is specifically designed as a middleware for Redux. It seamlessly integrates with the existing Redux middleware ecosystem and provides a straightforward way to handle asynchronous actions.

  5. Development Experience: Zustand aims to provide a modern, developer-friendly experience by leveraging the power of React hooks. It embraces the functional programming paradigm and encourages a more declarative and concise coding style. On the other hand, redux-thunk follows the traditional Redux pattern, which requires more boilerplate code and can be less intuitive for developers new to Redux.

  6. Community and Ecosystem: Redux has a massive and active community, which translates into a vast ecosystem of third-party libraries, tutorials, and community support. Redux-thunk benefits from this ecosystem, with many plugins and extensions available for various use cases. Zustand, being a relatively newer library, has a smaller community and ecosystem, but it is growing steadily.

In summary, Zustand and redux-thunk offer different approaches to state management. Zustand focuses on simplicity, performance, and a minimalistic design, while redux-thunk leverages the power of Redux middleware for handling asynchronous actions. The choice between the two depends on your specific requirements and preferences.

Manage your open source components, licenses, and vulnerabilities
Learn More
Pros of redux-thunk
Pros of Zustand
  • 6
    Easy
  • 10
    Simple API
  • 7
    Unopinionated
  • 5
    Asynchronous action out the box
  • 4
    Supports Redux DevTools
  • 3
    Less boilerplate
  • 3
    Open source
  • 2
    LIghtweight

Sign up to add or upvote prosMake informed product decisions

Cons of redux-thunk
Cons of Zustand
    Be the first to leave a con
    • 2
      Requires function component

    Sign up to add or upvote consMake informed product decisions

    82
    2.6K
    80
    264
    - No public GitHub repository available -

    What is redux-thunk?

    Redux Thunk middleware allows you to write action creators that return a function instead of an action. The thunk can be used to delay the dispatch of an action, or to dispatch only if a certain condition is met. The inner function receives the store methods dispatch and getState as parameters.

    What is Zustand?

    Small, fast and scaleable bearbones state-management solution. Has a comfy api based on hooks, that isn't boilerplatey or opinionated, but still just enough to be explicit and flux-like.

    Need advice about which tool to choose?Ask the StackShare community!

    Jobs that mention redux-thunk and Zustand as a desired skillset
    What companies use redux-thunk?
    What companies use Zustand?
    Manage your open source components, licenses, and vulnerabilities
    Learn More

    Sign up to get full access to all the companiesMake informed product decisions

    What tools integrate with redux-thunk?
    What tools integrate with Zustand?
    What are some alternatives to redux-thunk and Zustand?
    redux-saga
    An alternative side effect model for Redux apps
    Redux Observable
    It allows developers to dispatch a function that returns an observable, promise or iterable of action(s). Compose and cancel async actions to create side effects and more.
    jQuery
    jQuery is a cross-platform JavaScript library designed to simplify the client-side scripting of HTML.
    React
    Lots of people use React as the V in MVC. Since React makes no assumptions about the rest of your technology stack, it's easy to try it out on a small feature in an existing project.
    AngularJS
    AngularJS lets you write client-side web applications as if you had a smarter browser. It lets you use good old HTML (or HAML, Jade and friends!) as your template language and lets you extend HTML’s syntax to express your application’s components clearly and succinctly. It automatically synchronizes data from your UI (view) with your JavaScript objects (model) through 2-way data binding.
    See all alternatives