Hotwire vs htmx - comparison

Broadly speaking, I think Hotwire and htmx have similar goals. I haven’t personally used htmx, but I can offer my own biased (:angel:) first impression based on the web site, which opens by asking:

  • Why should only <a> and <form> be able to make HTTP requests?
  • Why should only click & submit events trigger them?

The Hotwire philosophy is progressive enhancement, which I might characterize this way, in response:

If the web offers us guidance, take it. The web gives us <a> to change pages and <form> to change server-side state, so that’s what we’ll use in our app. That way we have fewer decisions to make and we’re responsible for less code.

If we want to do something that can’t be done with HTML and CSS alone, we’ll still try to do as much as we can with HTML and CSS, and use a layer of JavaScript on top for the rest.

Hotwire is a conceptual umbrella that unifies Turbo (formerly Turbolinks, dating back to 2012) and Stimulus (from 2018) with a set of conventions which can be used with any server-side framework.

When paired with a REST back-end like Rails that renders and serves HTML, there’s a clear path for your Hotwire app to cover as much of the progressive enhancement spectrum as you want, without having to maintain multiple codebases.

Your Hotwire app can run on a browser with limited or no JavaScript, on smartphone and desktop browsers of all shapes and sizes and versions, and on native apps for Android and iOS with Turbo Native and Strada (coming soon).

htmx looks like an interesting domain-specific language on top of HTML, but it doesn’t subscribe to the progressive enhancement philosophy, as far as I can tell. There’s no real story for native apps like Hotwire has, and I don’t see how an htmx app could ever work with JavaScript disabled.

Those things may or may not be important to you. We didn’t explicitly build HEY to work with JavaScript disabled, for example—we kind of just get it for free by adopting the Hotwire conventions. But the native apps which sit at the other end of the spectrum are critical to our business, and those are built on the same conventions: links and forms and HTML with the last bit of native fidelity sprinkled on top as progressive enhancement.

9 Likes