State management in ReScript React

Has anyone used some of the state management libraries long-term with ReScript?

Do you have some insights to share?
Would you recommend it, or avoid it?
Have you encounter limitations?

For example:

1 Like

My thoughts are that there’s no real difference in picking a state management solution for a rescript-react or any other react app. Think about how you want the state to work in your app and select the solution that suits your needs.

With that being said, we’re using jotai and relay in our app. And I find both a joy to use with ReScript.


In our customer application we have used react-query and react context. It was quite sufficient for a complex form based application. Almost very minimal ui state was required to be maintained in context. Although it would vary from project to project.

Not a direct answer but something you could consider

I use SWR for persisting/syncing state from the server and Recoil for few things in the front-end. The only issue with Recoil is that sometimes it has glitches if you use hot reloading but it’s not bad at all anymore.
Jotai boasts for their simplicity but I’ve seen that they are consistently changing things and adding more complexity so I rather wait a bit to see. Recoil’s API seems pretty stable.

I agree that any state management would do it, but am hoping to:

  • hear people’s pains and experience with these libraries; things that you can’t read in the documentation, or learn after a 2 week test project - things that you learn after using a library for a few months and encountering weird limitations, over-rigid structure, or an API that simply doesn’t translate well to rescript (like too dynamic arguments, or lack of type safety)
  • have a thread that other newcomers can read and decide for themselves (I couldn’t find a state management thread in the forum)

Thanks Sriky, I’ve found that local state management and react context work up to a point, when you reach a need for real state management, which leads to time consuming refactors, so am hoping to avoid that and start with one upfront

@mellson @jorge have you had any highlights of using jotai and recoil? Do you ‘love’ the experience of using them, or is it ‘okay’ / they do the job? What about time consuming problems you’ve encountered?
(I’ve heard people are quite pleased with mobx, but it is unclear how it would support concurrent mode and how its API translates to rescript)

I’ve been enjoying that you can read or update the state using jotai without rerendering. Also that you can easily use local-state for storing something on the users end. It was a bit cumbersome to get started, mainly because writing bindings is one of the few rough edges with rescript (for me, at least). I enjoy using jotai, but not so much when there’s a new version published because I fear that our bindings will break.

In our app we mainly use relay, through the excellent rescript-relay library by @zth. If it’s possible for you to consider relay please have a look.