In his Rails World talk, Jeremy Smith uses the metaphor of spicy hot sauces to highlight common pitfalls and best practices when working with Hotwire’s Stimulus, Turbo Drive, Turbo Frames, and Turbo Streams, emphasizing simplicity, server-side logic, and careful management of navigation and real-time updates. He advises developers to avoid overcomplicating controllers, be cautious with Turbo’s defaults, and decouple broadcast logic, encouraging ongoing experimentation while keeping implementations as “mild” and maintainable as possible.
In his Rails World talk “Practical Hotwire: Stimulus & Turbo on the Ground,” Jeremy Smith uses the metaphor of spicy hot sauces to explore the lessons and pitfalls developers encounter when working with Hotwire, a modern Rails front-end toolkit. He opens by reflecting on how developers build judgment through experience—by “taking a bite and feeling the burn”—and suggests that while many Rails developers know what can go wrong in Rails, fewer are aware of the common mistakes and trade-offs in Hotwire. The talk aims to illuminate these “burns” across Hotwire’s main components: Stimulus, Turbo Drive, Turbo Frames, and Turbo Streams.
Smith begins with Stimulus, emphasizing its role in wiring JavaScript behavior to HTML with minimal code. He warns against overcomplicating controllers by coupling too many behaviors, advocating instead for small, composable controllers. He also highlights the importance of letting the server handle logic whenever possible, rather than duplicating validation or data processing on both client and server. This approach reduces maintenance overhead and leverages Hotwire’s strengths in server-side rendering.
Moving to Turbo Drive, Smith discusses how it enhances navigation by intercepting links and form submissions, but cautions about lifecycle issues—such as failing to clean up JavaScript behaviors or temporary UI states when navigating between pages. He also critiques Turbo’s default prefetching behavior, which can cause unnecessary server load and side effects if not managed carefully. His advice is to disable prefetching globally and enable it only where the performance benefit justifies the cost.
With Turbo Frames, Smith explores common errors like the “content missing” problem, which occurs when responses lack the expected frame ID, often due to overlooked edge cases or conditional rendering. He warns about the performance pitfalls of overusing frames for lazy loading, which can lead to an explosion of server requests and make performance issues harder to diagnose. He also describes the “dead end” scenario, where frames can only update one region of a page, and recommends switching to Turbo Streams when multiple regions need to be updated in response to a single action.
Finally, Smith delves into Turbo Streams, emphasizing the importance of precise DOM targeting and the challenges of broadcasting updates in real-time applications. He illustrates how improper scoping or over-reliance on model callbacks can lead to data leaks or performance issues, and suggests decoupling broadcast logic from model lifecycles. For personalization challenges—such as rendering user-specific content in broadcasts—he demonstrates how to depersonalize server-rendered partials and apply client-side personalization with Stimulus. Smith concludes by encouraging developers to keep experimenting and learning from mistakes, while maintaining a “mild” approach to avoid unnecessary complexity, and points viewers to practicalhotwire.com for further resources.
Useful Links
- Practical Hotwire Slides by Jeremy Smith — Directly related to the talk content and examples discussed.
- Practical Hotwire Code Samples and Resources — Contains practical examples and resources directly related to the talk’s content.