A Ruby gem that seamlessly integrates the Stimulus JavaScript framework into Rails applications with automatic setup for import maps or bundlers.
Stimulus for Rails is a Ruby gem that integrates the Stimulus JavaScript framework into Ruby on Rails applications. It provides automatic setup and configuration for both import-mapped and JavaScript-bundled Rails apps, making it easy to add interactive behavior to HTML without heavy front-end frameworks. The gem is part of the Hotwire ecosystem and works seamlessly with Turbo to build fast, modern web applications.
Rails developers who want to add modest JavaScript interactivity to their applications without adopting a full front-end framework like React or Vue. It's ideal for teams using Hotwire or those preferring server-rendered HTML with progressive enhancement.
Developers choose Stimulus for Rails because it eliminates the configuration overhead of setting up Stimulus manually in Rails, supports both modern JavaScript approaches (import maps and bundlers), and integrates tightly with Rails conventions and generators. Its automatic controller registration and lazy/eager loading options streamline development while keeping the front-end lightweight.
Use Stimulus in your Ruby on Rails app
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The installer automatically detects whether your Rails app uses import maps or JavaScript bundlers and configures Stimulus accordingly, simplifying initial setup as described in the installation section.
It seamlessly supports both import-mapped and JavaScript-bundled Rails apps, with tailored instructions for each in the README, ensuring flexibility for modern Rails workflows.
Automatically registers Stimulus controllers based on file structure, with options for eager or lazy loading, reducing boilerplate code as outlined in the usage sections.
Includes Rails generators to create new Stimulus controllers and update the controller manifest automatically, speeding up development and maintaining consistency.
Pairs beautifully with Turbo as part of the Hotwire stack, providing a complete solution for fast, modern applications without heavy front-end frameworks.
Requires either importmap-rails or jsbundling-rails to be installed first, adding an extra layer of setup and potential compatibility issues for non-standard Rails configurations.
The README admits that manual installation is necessary if the installer encounters errors, such as conflicts with existing files, which can be time-consuming and error-prone.
For import-mapped apps, lazy loading is recommended for many controllers, which can introduce debugging challenges and increase initial configuration complexity, as noted in the usage section.
Tightly coupled with Rails conventions and ecosystems, limiting its usefulness for hybrid applications or teams transitioning away from Rails, as it lacks standalone flexibility.