'React along with Stimulus js in Rails 6

Is there a way to use reactjs along with stimulusjs simultaneously in a an existing rails project?

This is not a coding specific question rather an architectural approach. Is it possible?



Solution 1:[1]

I was asking myself this same question, and I found multiple resources.

The general idea on how I would prefer to use it is to use StimulusJS for most things, and where you need some powerlifting, mount React app and use it.

So what I will do here is list the resources that look helpful. Also, if I find time, I will try to update this answer with my use case and how I set this up with the mentioned resources below. (I might even create a blog post)

  • Clay Murray's simple and awesome article (source: DEV.to)
  • David Guilfoyle's article (the author claims that this works with Turbolinks/Turbo as well) (source: Medium)
  • DanBridges' article on using pre-built React components with Rails + StimulusJS (source: a blog post)

Kudos go to the guys mentioned in the resources!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1