htmx extends HTML with attributes so pages can trigger AJAX, CSS transitions, WebSockets, and server-sent events without writing custom JavaScript for each interaction.
Overview
htmx lets developers build interactive interfaces while keeping hypertext as the primary model. Attributes such as hx-post and hx-swap declare that an element should issue HTTP requests, listen for events beyond click and submit, use methods beyond GET and POST, and swap partial page regions instead of full reloads.
The library is small, dependency-free, and designed to be extended. It positions itself as completing HTML for modern UIs: server-rendered responses can replace fragments, drive transitions, or stream updates. htmx succeeds the earlier intercooler.js project and ships as an npm package distinct from unrelated packages named htmx.
A major release line dropped legacy Internet Explorer support; a parallel older line remains for environments that still require IE. Documentation and a companion book on hypermedia-driven applications explain patterns for structuring server endpoints and markup. Sponsorship supports ongoing maintenance.
Typical usage adds attributes to existing elements—for example, a button that POSTs to an endpoint and replaces itself with the HTML response—so backends return HTML snippets rather than JSON consumed by large client frameworks.
Key features
- Declarative AJAX via HTML attributes
- Partial page swaps and targeting
- WebSocket and SSE attribute hooks
- CSS transition integration
- Small minified bundle size
- Extension points for custom behavior
- npm package installation
- Hypermedia-driven UI patterns
Use cases
- Progressive enhancement of server-rendered apps
- Replacing full page reloads with fragments
- Live updates over WebSockets or SSE
- Reducing custom frontend JavaScript glue