Re:Hotwire: HTML Over The Wire
by whartung on Sunday June 02, 2024 @12:47PM
(#40555469)
How does this contrast to htmx?
[ Parent
| on HN ]
Re:Hotwire: HTML Over The Wire
by felipemesquita on Sunday June 02, 2024 @01:06PM
(#40555638)
Hotwire is the umbrella term for turbo, stimulus and strada. Turbo has client and server side components that enable easy ways to do partial page refreshes and send html templates (turbo streams) to initiate page updates from the server. That’s all without writing any js (using mostly data attributes and custom html tags, like turbo-frame).
Stimulus comes in as a small framework for the cases where you want to write some JavaScript, in a way that you still control the behavior from html, by attaching controllers to elements explicitly.
These two aspects are similar to htmx:
- send html from the server even for partial page updates
- encode desired js behavior into the html
The main difference is that turbo is designed with a convention over configuration attitude, as many of it’s behaviors are automatic (like intercepting all form submissions and handling them using fetch, preventing a full page reload). When custom js is needed Hotwire defers to letting you write actual js code, htmx has this tailwind style shorthand that allows you to basically write js from the html.
Re:Hotwire: HTML Over The Wire
by andrei_says_ on Sunday June 02, 2024 @02:30PM
(#40556250)
I’d add - stimulusjs lets you write your own htmx-like functionality by providing a convention for triggering and passing data to js via html data attributes.
The stimulus JavaScript controllers (not to be mistaken with the Rails mvc controllers) are reusable and nest-able which makes them very powerful and quite fun to write.
Hotwire integrates with Ruby on Rails. (EDIT: The linked page shows how to integrate Hotwire with Ruby on Rails. See fxn's comment https://news.ycombinator.com/item?id=40555577)
I had the same question, then watched the video to get the answer.
No, Hotwire is framework agnostic it is web components and JavaScript, basically.
You can Google Hotwire with Django, or Laravel, or many others (https://hotwire.io/frameworks).
Thanks for the information.
The linked page shows only integrating Hotwire with Ruby on Rails, giving me my original impression.
Some links do not have information yet, others do, for example https://hotwire.io/frameworks/laravel or https://hotwire.io/frameworks/django.
> framework agnostic
Framework agnostic but Ruby-only it seems.
Re:Hotwire: HTML Over The Wire
by andrei_says_ on Sunday June 02, 2024 @02:33PM
(#40556275)
Hotwire is in JS and is used by multiple back-end frameworks including Rails.
Rails has a lot of affordances for Hotwire and is the back end framework for which Hotwire was originally written.
No. Turbo is js and HTML.
If your backend can send templates down the websocket, you can use Hotwire.