DEV Community

Cover image for Context API vs Redux
Uriel Bitton
Uriel Bitton

Posted on

Context API vs Redux

React's context api is a gift from heaven. It is super easy to understand and make use of. I use it in every react app. You simply create your state, export it and in your app.js you wrap the ContextProvider around your app component and your done! Managing state across your app is incredibly smooth and simple.

I learned redux this past week and the first thing that came to my mind was: complicated. Its not as intuitive as the context api and it took me a while to get the flow and i didn't really like it that much.

What are your thoughts on redux compared to context, which do you prefer and why? Do you think Redux is a dinosaur now that context api is becoming more popular. Let me know below!

Top comments (7)

Collapse
 
neeldev96 profile image
Neel

I use context api in my open source project and redux in my workplace. Context api makes global state management a piece of cake. But I like redux devtools which makes state visualization super easy. Is there anything similar for the context api?

Collapse
 
urielbitton profile image
Uriel Bitton

well there is the native react devtools which may help but honestly the context api makes it so intuitive that i really dont need anything more!

Collapse
 
sskanishk profile image
Kanish Malviya

React's context API is still not up to the mark as compared to redux in terms of state management and state tracking. context API might slow at times but redux is smart enough to keep performance up.
But still, it depends on choice and project size. :)

Collapse
 
andrewbaisden profile image
Andrew Baisden

Hooks and context and much more lightweight as Redux requires a lot of boilerplate to set it up. However many companies still prefer to use Redux so its good to know all 3. I think Redux is better for large projects. The other two are better for small and medium.

Collapse
 
scottscalablepath profile image
Scott Cosentino

Context API definitely has a few benefits over Redux. It is scalable, less complex, and easy to maintain and reuse. Depending on the use case, Context API can be a great choice for handling data flow. If you're interested, one of our developers did a deep dive comparing the two options on our blog.

Collapse
 
madza profile image
Madza • Edited

Redux -> Context API (16.3.)
Classes -> Hooks (16.8.)
are probably the main reasons I'm still with React 😉

Collapse
 
urielbitton profile image
Uriel Bitton • Edited

Haha yes for sure. Hooks and context are soo much better!