PROVIDER Β· the tiny library adding partial updates through HTML attributes
htmx
htmx declares interaction through HTML attributes like hx-get and hx-target, giving Django, Laravel, and Rails server-rendered projects SPA-like fluidity without client frameworks or state management.
Pros
Cons
Product Information
Detailed Notes
Overview
htmx was released in 2020 from intercooler.js origins as roughly a 14KB library declaring behaviour through HTML attributes such as hx-get, hx-post, and hx-target, specifying where to request and where to place returned HTML fragments without JavaScript or a state layer.
For Programming Languages & Frameworks work the value is server rendering with partial updates, since Django, Laravel, and Rails template projects gain SPA-like fluidity without adopting React, HTML from the server is inherently SEO and first-paint friendly, and code volume stays far below separated frontend stacks.
Recognise the boundaries, because complex client state such as dragging, realtime collaboration, and offline does not fit, many partial updates load the server, teams must relearn hypermedia thinking which differs sharply from SPA habits, and the ecosystem remains smaller with limited component reuse.
Core Strengths
- About 14KB needing no build tooling
- HTML attributes declare interaction with no JS or state layer
- Server templates such as Django, Laravel, and Rails stay inherently SEO friendly
- Far less code than separated frontends with HTML responses over JSON
Product Ecosystem
Core attributes
hx-get, hx-post, hx-target, hx-swap, hx-trigger, hx-vals, and hx-indicator.
Interaction patterns
Partial replacement, infinite scroll, live form validation, optimistic UI, and polling.
Server pairing
Servers return HTML fragments rather than JSON, with SSE or WebSocket for realtime.
Drawbacks
- Complex client state such as dragging, realtime collaboration, and offline does not fit
- Many partial updates increase server load
- Hypermedia thinking differs from SPA habits needing adaptation
- Ecosystem and component reuse trail mainstream frameworks
Use Cases
- Enhancing server-rendered projects (β β β β β ) - No SPA needed
- Admin panels and form flows (β β β β β ) - Efficient partial updates
- Content and SEO-sensitive pages (β β β β β ) - HTML output friendly
- Complex rich interaction apps (β β ) - Needs client frameworks
Pricing
| Plan | Price | Scope |
|---|---|---|
| htmx | $0 | BSD 2-Clause, entirely free |
| Official extensions | $0 | Open source and free |
| Hosting and CDN | From $0 | Free CDN tiers |
Entirely free, and without build pipelines or a frontend framework the engineering and staffing cost drops well below separated stacks, saving a whole frontend toolchain for CRUD-heavy projects.
FAQ
-
Will htmx replace React? No, it addresses template rendering with partial updates while complex state and rich interaction still need client frameworks, and they coexist.
-
Is performance sufficient? Enough for CRUD and admin systems, where frequent partial updates such as live suggestions need debouncing and server optimisation.
-
Is JavaScript required? Barely, with small additions through htmx event APIs only for special interactions.
Code Examples
Partial updates via HTML attributes
<button hx-get="/api/plans"
hx-target="#list"
hx-swap="innerHTML"
hx-indicator="#spinner">
Load data centers
</button>
<span id="spinner" class="htmx-indicator">Loadingβ¦</span>
<ul id="list"></ul>
The server returns an HTML fragment and the browser swaps it in without any frontend JavaScript.
Progressive enhancement with hx-boost
<body hx-boost="true">
<a href="/plans/">Data center list</a>
<form hx-post="/api/plans" hx-target="#result">
<input name="name" required>
<button type="submit">Add</button>
</form>
</body>
Links and forms fall back to normal navigation without JS, htmx's main advantage over SPAs.
Community & Resources
Communities and official channels
- htmx Site β Docs, examples, and philosophy
- GitHub bigskysoftware/htmx β Source, issues, and releases
- Stack Overflow #htmx β Attributes and server integration
Learning resources and tools
- htmx Docs β Attribute reference and patterns
- htmx Examples β Copyable examples of common patterns
- htmx Essays β The author's essays on frontend architecture