Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

redux-saga vs rtk-query,what is better to choose? [closed]

i've tried to watch many videos about redux saga and rtk query but still can't choose,so please can any body help me with that, like when better use saga and rtk query,and which one is the best now?

like image 296
Remi Avatar asked Aug 31 '25 16:08

Remi


1 Answers

They are not even doing the same thing.

RTK Query is a single-purpose tool to manage api caching logic for you.

Redux Saga is an orchestration tool that allows you to do pretty much anything - but you have to write it yourself. And that might mean a lot of code to write.

So the base question is "do I need something to trigger an api" or "do I want to write code myself to do something". After that you get the question is Redux Saga is a good idea at all - and most of the time, it isn't. Redux Saga is a power tool with a lot of functionality - that also adds a lot of complexity. The recommendation from the Redux Style Guide is to use the most simple tool for every job: Use Redux Thunk for async logic. If you are one of the 10% apps that needs "reactive logic", use the RTK listener middleware (only for those things, stay with thunks for the simple stuff!). Only if you belong to those 1% of apps that needs something that is actually not possible with those two much more simple tools, use saga. And even then, mix it with thunks.

like image 53
phry Avatar answered Sep 05 '25 10:09

phry