Search code examples
reduxversionredux-saga

Is it worth using Redux-Saga in the long term?


Redux-Saga, a Redux side effect manager, is said to be deprecated, and no longer being maintained.

Yet, over 1 million developers download this NPM package weekly, regardless of the fact that the last 1.1.3 version of Redux-Saga was published almost 3 years ago.

What issues might I face if I keep on using Redux-Saga for the long term, even if it is no longer being maintained by its authors?


Solution

  • I'm a Redux maintainer.

    Today, we specifically recommend against using sagas in almost all use cases!

    To be clear: Sagas are a great power tool, like a chainsaw. If you really need that power, then having that tool is important. But most of the time, you don't need a chainsaw on a daily basis.

    I actually just gave a talk on this specific topic:

    Reactathon 2022: The Evolution of Redux Async Logic

    In that talk I described different techniques for dealing with async logic and side effects in Redux apps, and gave our set of recommendations for what you should use today. I'll paste in the last slide here for reference:

    Our Recommendations Today

    What use case are you trying to solve?

    Data Fetching

    • Use RTK Query as the default approach for data fetching and caching
    • If RTKQ doesn't fully fit for some reason, use createAsyncThunk
    • Only fall back to handwritten thunks if nothing else works
    • Don't use sagas or observables for data fetching!

    Reacting to Actions / State Changes, Async Workflows

    • Use the RTK "listener" middleware as the default for responding to store updates and writing long-running async workflows
    • Only use sagas / observables in the very rare situation that listeners don't solve your use case well enough

    Logic with State Access

    • Use thunks for complex sync and moderate async logic, including access to getState and dispatching multiple actions