DEV Community

loading...
Cover image for Context API vs Redux

Context API vs Redux

Uriel Bitton
Hi i'm an avid web and app developer in search for creativity and always going after new ideas. Developer of Reactor JS
・1 min read

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!

Discussion (6)

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
neel1996 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 Author

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
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
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 Author • Edited

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

Forem Open with the Forem app