Stimulus and other *front-end frameworks not documented in rails

I really love StimulusJS but I had it took me a bit of time to integrate it with rails. There’s no section for stimulus and rails in the docs yet there droves of people using this beautiful library. Regardless of the fact that it is an independent JS library, it is the de facto way to add some sprinkles of JS and therefore it should be somewhere in the official docs IMO.

I have also had times where I thought a front end framework like Vue or Svelte would do the trick for me e.g. Svelte comes with transitions baked in and a sprinkle of Svelte in a rails app could come in handy. In some cases, I can even write fewer lines of code than I would if I would opt for Stimulus controllers. I thinks Rails should provide some useful documentation of how to play around with other frameworks.

1 Like

Webpacker has a configuration option to set up Stimulus somewhere. There’s an effort to clean up the JS documentation in https://discuss.rubyonrails.org/t/javascript-documentation-coordination/74970/17

1 Like

Thanks for the pointer. I’ll look out for the ‘integrations with frameworks’ part once the ball gets rolling at https://github.com/noelrappin/rails_javascript_documention_drafts/blob/master/webpacker_guide.md

I’ve enjoyed playing with Svelte in my Rails app. I pass arguments from the Rails view to the Svelte component with a svelte_component helper as shown below. Might be helpful to have this kind of thing documented or even having a gem for it.

Thanks Seb. I think most of the gems for front-end frameworks are outdated. React has some very good gems with great documentation prior to the introduction of hooks but hey, it’s 2020 and I can’t be writing React when there are so many things that allow me to do so much more with less. I’ll try to use your svelte config and see how it goes!