Welcome
What is StimulusReflex?
A new way to craft modern, reactive web interfaces with Ruby on Rails.
We extend the capabilities of both Rails and Stimulus by intercepting user interactions and passing them to Rails over real-time websockets. These interactions are processed by Reflex actions that change application state. The current page is quickly re-rendered and the changes are sent to the client using CableReady. The page is then morphed to reflect the new application state. This entire round-trip allows us to update the UI in 20-30ms without flicker or expensive page loads.
This architecture eliminates the complexity imposed by full-stack frontend frameworks without abandoning high-performance reactive user experiences. With StimulusReflex, small teams can do big things faster than ever before. We invite you to explore a fresh alternative to the Single Page App (SPA).
Why should I use StimulusReflex?
Wouldn't it be great if you could focus on your product instead of the technical noise introduced by modern JavaScript? With StimulusReflex, you'll ship projects faster, with smaller teams and re-discover the joy of programming.
Goals
- โ Enable small teams to do big things, faster ๐๐ฝโโ๏ธ
- โ Increase developer happiness โค๏ธโค๏ธโค๏ธ
- โ Facilitate simple, concise, and clear code ๐คธ
- โ Integrate seamlessly with Ruby on Rails ๐
New Release: v3.4 - Developer Happiness Edition
Find out more and learn how to upgrade on the Release History page.
Faster UIs, smaller downloads and longer battery life
Our over-the-wire JavaScript payload size is a tiny 11.4kb gzipped... and that includes StimulusReflex, ActionCable, morphdom and CableReady.
While StimulusReflex is a radically different approach that makes it hard to do a direct comparison to the popular SPA frameworks, the one thing everyone seems to agree on is how small their Todo List implementation is. Here're the numbers:
Tool | Wire Size |
---|---|
StimulusReflex | 54kb |
React | 268kb |
Angular | 290kb |
Vue | 78kb |
Ember | 169kb |
Not everyone has the latest iPhone in their pocket. We're delivering HTML to the client, which every device can display without a framework rendering a UI from JSON. We reduce complexity for developers while making it easier for people with slower connections and less-powerful devices to access your site without draining their battery.
Live demo
StimulusReflex Expo is a growing collection of like examples showing different use-cases alongside the source code behind them.
Some of our favorite demos include:
- Tabular: filtering, sorting and pagination without any client JavaScript
- Todo: our take on the classic, with a wire size 2-15x smaller than every other solution
Another excellent demo is BoxDrop.
Build the next Twitter in just 9 minutes (or less) ๐
This demo from early 2020 is exciting, but it is not a tutorial!
First-class ViewComponent support
When you have ViewComponent installed in your project, you can use componentized views in your Reflexes without any configuration required. ๐ฏ
If you install the amazing ViewComponentReflex as well, you will be able to persist the state of your components into the user's session. Every instance of your components will maintain their own local state. This provides seamless continuity for your UI - even when doing full-page Reflex updates. Hand, meet glove. ๐๏ธ+๐งค
Some things just have to be seen: check out the ViewComponentReflex Expo for live demos.
How we got here
We love Rails. Veterans of the framework remember the feeling of awe and disbelief after seeing David Heinemeier Hansson's Build a Blog in 15 minutes video. It didn't seem possible that web development could be so easy, productive, and fun. We're talking exponential gains in developer efficiency and happiness. Rails has become so successful that nearly every framework since has borrowed ideas, patterns, and features from it.
The landscape has changed a lot since those early days. Applications are more ambitious now. The pursuit of native UI speeds spawned a new breed of increasingly complex technologies. Modern Single Page Apps have pushed many of the server's responsibilities to the client. Unfortunately this new approach trades a developer experience that was once fun and productive for an alternative of high complexity and only marginal gains.
There must be a better way.
The revolution begins
In his 2018 ElixirConf keynote, Chris McCord (creator of the Phoenix framework for Elixir) introduced LiveView, an alternative to the SPA. His presentation captures the same promise and excitement that Rails had in the early days.
We love Elixir and Phoenix. Elixir hits a sweet spot for people who want Rails-like conventions in a functional language. The community is terrific, but it's still small and comparatively niche.
Also, we just really enjoy using Ruby and Rails.
StimulusReflex was originally inspired by LiveView, but we are charting our own course. Our goal has always been to make building modern apps with Rails the most productive and enjoyable option available. We want to inspire our friends working with other tools and technologies to evaluate how concepts like StimulusReflex could work in their ecosystems and communities.
So far, it's working! Not only do we now have 20+ developers actively contributing to StimulusReflex, but we've inspired projects like SockPuppet for Django.
We are truly stronger together.