Skip to content

vs htmx / Hotwire ​

htmx and Hotwire (Turbo + Stimulus) are both "HTML over the wire": the server returns HTML and the browser swaps it in. Render fragments belong to the same family, and like htmx they don't care about the back-end language, which is exactly why the same JS could move from PHP to Rust. The differences are in three places.

1. Where in-progress state lives ​

htmx / TurboThis runtime
Expanded sections, tabs, unsaved inputUsually in the DOM (classes, hidden, field values)Client state (data-state-*)
After the HTML is replacedKept by morphing or preserved regions, otherwise lostThe new nodes read the old values back when they're bound

That's why render fragments dare to "replace the whole thing without diffing": what needs to be kept was never in the DOM being replaced.

2. How the server directs the browser ​

htmxTurbo StreamsLinker
FormEvents triggered by response headers, hx-swap-oob<turbo-stream action="…">Named actions in a pipeline
Scope of actionsSwapping sections + custom eventsappend / replace / remove… + custom actionsThe few registered in the action table
Business dataWrapped in HTMLWrapped in HTMLdata written to state; data-state-* display themselves

Linker separates "data" from "HTML": updating a single number doesn't need a block of HTML.

3. Who can be called ​

htmx / TurboThis runtime
EndpointsAny URL; whatever the attribute says gets requestedFragments: only names registered with render::register; Linker: only registered aliases + METHODS
Endpoint locationUp to youUnder one prefix derived from APP_KEY; four fixed routes
Permissions on front-end attributesNoneThe render object's allow list (a development-time boundary)

htmx style (the Rust back end writes a route that returns HTML):

html
<input name="q" hx-get="/customers/search" hx-trigger="input changed delay:400ms" hx-target="#results">
<div id="results">…</div>

This runtime:

html
<main{{ panel_attrs }} data-state-init="keyword=">
    <input name="keyword"
           data-state-bind="keyword"
           data-linker-call="search"
           data-linker-on="input"
           data-linker-debounce="400"
           data-linker-args="keyword">
    <p><span data-state-text="matchCount">{{ total }}</span> matches</p>
    <table>…<tr class="hidden" data-linker-ref-dom="customers">…</tr>…</table>
</main>

What you gain: only listed methods can be called, the server validates arguments and authorization (user.authorize), error handling is fixed, the count doesn't have to be HTML, the list uses dom.repeat without going through the HTML parser, and the search box keeps its text after a redraw. The full version is in the searchable list tutorial.

The cost: more concepts (render objects, state, Linker), whereas htmx gets you started with one attribute.

When to choose htmx / Hotwire ​

  • You want the fewest concepts and the largest ecosystem.
  • Page interaction is simple, and state in the DOM can safely be replaced.
  • You don't need to share screens with the PHP CGWebFramework.

In the Rust ecosystem, htmx with axum / Askama is a very mature combination; if you don't need Linker's state model and action table, that path is simpler.