HTMX
Open SourceHigh power tools for HTML.
Scores
About
HTMX is a lightweight (~14kb gzipped) JavaScript library that extends HTML with attributes for making AJAX requests, handling CSS transitions, and consuming WebSockets and Server-Sent Events — all without writing custom JavaScript. Instead of building a JSON API consumed by a separate frontend framework, HTMX lets your server return HTML fragments that are swapped directly into the DOM.
Hypermedia-driven architecture. HTMX embraces the original web model: the server is the source of truth, responses are HTML, and navigation happens via hypermedia controls. You annotate HTML elements with attributes like hx-get, hx-post, hx-target, and hx-swap to declaratively define interactions. This eliminates the need for a separate REST/JSON API layer and a client-side rendering framework in many cases.
Backend-agnostic. HTMX works with any server that can return HTML — Django, Flask, FastAPI, Rails, Laravel, Spring Boot, Go's net/http, Gin, Express, and more. There is no build step, no npm, and no bundler. You include a single <script> tag and start adding attributes.
HTMX 2.0 (released 2024) refined the API, improved performance, and removed deprecated features. The core attribute set remains the same: hx-get/post/put/patch/delete for HTTP methods, hx-target for DOM targeting, hx-swap for swap strategies (innerHTML, outerHTML, beforeend, etc.), and hx-trigger for event-based activation.
Extension ecosystem. Official extensions add capabilities like client-side template rendering, path delegation, response handling with hyperscript, and debugging tools. The hx-on attribute provides inline event handling for simple cases.
HTMX is particularly well-suited for server-rendered applications, internal tools, dashboards, CRUD-heavy interfaces, and teams that want to avoid the complexity of SPA frameworks like React, Vue, or Angular.
Key Features
- AJAX via HTML attributes — hx-get, hx-post, hx-put, hx-patch, hx-delete with no JavaScript
- CSS Transitions and animations triggered by DOM swaps
- WebSocket and Server-Sent Events support via hx-ws and hx-sse attributes
- Declarative DOM targeting — hx-target and hx-swap control where and how HTML fragments are inserted
- Event-driven triggers — hx-trigger supports click, load, reveal, intersect, and custom events
- Backend-agnostic — works with any server that returns HTML (Python, Go, Ruby, PHP, Java, etc.)
- No build step, no npm, no bundler — single script tag inclusion (~14kb gzipped)
- Extension system for client-side templates, path delegation, and more
Pros
- Dramatically simpler than SPA frameworks — no build tools, no npm, no client-side state management
- Works with any backend language; ideal for teams with strong server-side skills
- Tiny footprint (~14kb gzipped) with no framework runtime overhead
- Excellent for server-rendered apps, CRUD interfaces, and internal tools
- Progressive enhancement — pages work without HTMX, enhanced with it
- Strong community and excellent essays/reference docs at htmx.org
Cons
- Not suited for highly interactive client-heavy apps (real-time editors, complex drag-and-drop UIs)
- Server returns HTML fragments — can lead to larger response payloads than JSON APIs for data-heavy views
- Smaller ecosystem than React/Vue — fewer third-party component libraries and pre-built UI kits
- Debugging can be harder when complex hx-trigger chains create implicit state machines
- Less relevant for teams already invested in a SPA architecture or requiring offline-first capabilities
Pricing
Open SourcePossible Stacks
HTMX + Django
ProjectA server-driven web stack where Django renders HTML templates and HTMX adds dynamic interactions without writing JavaScript. Ideal for teams that want fast iteration on CRUD-heavy apps and dashboards with minimal frontend complexity.
HTMX + FastAPI
ProjectA lightweight, fast Python stack. FastAPI serves HTML fragment endpoints, HTMX swaps them into the DOM, and Tailwind handles styling. Great for modern server-driven apps with async Python backends.
HTMX + Go (Gin)
ProjectA high-performance server-driven stack. Go with Gin serves HTML templates and fragment endpoints; HTMX handles browser-side DOM swaps. Minimal footprint, fast cold starts, excellent for performance-critical web apps.
Related Tools
Works well with (13)
Alternative to (6)
Learning Resources
No resources yet — check back soon.