DEV Community

Riku Rouvila
Riku Rouvila

Posted on • Edited on

Which state management library to use with React?

I'd start by not using any state management library. You can use React's built-in state management as long as you're not using the same state in 2 parts of your app. You can ship small apps without having to choose any.

Naturally, the need for sharing state arises sooner or later. This is a good time to consider Recoil. It's easy to learn and doesn't take over your whole codebase. It's also pretty great with TypeScript.

I'd also check out xstate.

What I've tried since React first came out

Top comments (3)

Collapse
 
psiho profile image
Mirko Vukušić

I'm already boring to myself, repeated 100 times probably everywhere, so it looks like I'm on their salary :) But... Mobx, Mobx, Mobx and maybe Mobx-tree. I started with Mobx when I started with React and am so happy with it I don't even want to look elsewhere. So easy to learn, feels so natural to use, almost like magic, like global variables :)
I can't state it's the best, especially not for everything, but if you haven't tried it then you simply have to put it on your list.

Collapse
 
rikurouvila profile image
Riku Rouvila

I think you are right, I should've tried it already! I'm glad you've found something that fits your needs so well that you cannot stop talking about it 😄 You reckon there will be a higher level abstraction created soon on top of Recoil, similar to what mobx-state-tree is?

I once had the honour to interview Michel Weststrate on our podcast webbidevaus.fi/43. What a great guy!

Collapse
 
psiho profile image
Mirko Vukušić

Yes, people behind projects matter as much as projects. I've read some interviews with Michael and I liked what he says. About abstraction levels and other state managements... Im far behind to know ;) I don't do so much projects lately, only occasional ones and haven't even built a complete mobx-tree project yet. Sometimes is just difficult to try all interesting things AND keep being efficient and productive in the same time. So stuck with Mobx for long and shifted my learning focus to AWS and Cloud Formation lately.