What changed
On August 28, 2026, the htmx project released htmx 4.0 after roughly eight months of development. The core networking layer has moved from `XMLHttpRequest` to the modern `fetch()` API, enabling a cleaner async implementation and new streaming behavior. Version 4 also changes attribute inheritance so inheritance must be explicit rather than assumed, standardizes event naming, stops using `localStorage` for history by default, and adds new `hx-download`, `hx-alpine-compat` and `hx-history-cache` features. The release includes first-party extensions for streaming HTML over Server-Sent Events, WebSockets and `multipart/mixed`, plus the new `hx-live` scripting layer and an `htmax.js` bundle. Despite the major release, the project is intentionally leaving htmx 2.x as npm's `latest` tag until early 2027 to avoid silently upgrading CDN and unpinned installations.
Why it matters
htmx is used precisely because it lets server-rendered applications add interactivity without adopting a large client framework. Version 4 modernizes that model without abandoning it, and the streaming extensions make incremental server-driven UI updates a more direct architectural option for AI outputs, long-running jobs and real-time applications. The migration also contains enough behavioral changes to deserve deliberate testing: inherited attributes and browser history can affect application behavior far from the code that triggered the request. By keeping 4.0 on npm's `next` channel, the project is explicitly treating the release as an opt-in compatibility boundary rather than forcing ecosystem-wide adoption.
The transport layer moves from XHR to fetch
htmx historically used XMLHttpRequest for broad backwards compatibility. Version 4 rewrites the core request path around `fetch()` and async JavaScript. For ordinary requests the project says behavioral differences from 2.x are relatively small, but the new foundation makes streaming responses and modern browser primitives substantially easier to support.
Streaming HTML becomes part of the official ecosystem
The 4.0 release includes `hx-sse` for `text/event-stream`, `hx-ws` for WebSockets and `hx-multipart` for `multipart/mixed` streaming responses. Instead of waiting for one complete HTML response, applications can progressively deliver server-rendered fragments. That is useful for long-running server work, live dashboards and AI generation where the server can emit meaningful UI before the whole job completes.
Attribute inheritance is intentionally less implicit
htmx 4 changes inheritance behavior so inherited attributes are explicit. This reduces hidden behavior travelling down large DOM subtrees, but applications that relied on 2.x inheritance can break even when the affected element itself was not edited. The project provides migration guidance and tooling because this is one of the more consequential compatibility changes.
History behavior changes to avoid persistent local storage by default
The default history path no longer stores htmx history snapshots in `localStorage`; version 4 prefers re-fetching content. A separate `hx-history-cache` extension can use `sessionStorage` when a client-side history cache is desired. Builders should test offline/back-navigation behavior, request load and pages whose historical state cannot be safely reconstructed from the server.
The project is deliberately preventing accidental upgrades
Although the website now documents 4.0, the htmx team says npm's `latest` tag will remain on the 2.x line until early 2027, while 4.0 stays under `next`. That protects users relying on unversioned CDN or package references but also means a normal update command may not move an application to the new major version.