htmx 4.0 Ships a Fetch-Based Rewrite With Built-In Morphing Swaps and a Breaking Attribute-Inheritance Change
htmx skipped version 3 and shipped 4.0, replacing XMLHttpRequest with fetch(), building in morphing swaps, and requiring an :inherited suffix for attribute inheritance.
Overview
The htmx project released version 4.0.0 of its open-source hypermedia library on August 28, 2026, skipping version 3 entirely after eight months of development, according to InfoQ and the htmx team’s release announcement, which describes the release as the culmination of eight months of work. The new version replaces the library’s long-standing XMLHttpRequest transport with the native fetch() API while keeping the script at roughly 14KB, according to InfoQ.
What We Know
- The fetch-based architecture enables native streaming support, according to InfoQ and the project’s official changes reference, which states that all requests now use the native
fetch()API instead of XMLHttpRequest and that this change cannot be reverted. - The most consequential breaking change is attribute inheritance: attributes that previously cascaded to child elements automatically now require an explicit
:inheritedsuffix, for examplehx-confirm:inherited, according to InfoQ, the htmx team’s announcement, and the official changes reference. InfoQ reports that credentials passed throughhx-headers, such as CSRF tokens, will silently stop reaching the server without the new suffix, producing 403 errors rather than an obvious failure, according to InfoQ. - Morphing swaps are now built into the library, preserving DOM state such as input focus during updates, according to InfoQ, the htmx team’s announcement, and the official changes reference, which lists new morph-based swap styles among the release’s additions.
- A new
hx-partialtag lets a single server response update multiple targets in one pass, offered as a cleaner alternative to out-of-band swaps, according to InfoQ, the htmx team’s announcement, and the official changes reference. - Event names now follow a
htmx:phase:actionpattern — for example,htmx:afterRequestbecomeshtmx:after:request— according to InfoQ, the htmx team’s announcement, and the official changes reference. - History handling changed: htmx 4 no longer snapshots the DOM into localStorage for back-navigation caching, and instead refetches pages, which the project says helps ensure third-party scripts keep functioning correctly, according to InfoQ, the htmx team’s announcement, and the official changes reference.
- The default request timeout changed from unlimited to 60 seconds, according to InfoQ and the official changes reference.
- Some attributes were renamed, including
hx-disablebecominghx-ignore, according to InfoQ and the official changes reference. - To avoid disrupting existing users, htmx 4.0 ships under npm’s “next” tag rather than “latest”: version 2.x keeps the “latest” tag and remains supported indefinitely, with 4.0 not set to take over as the default until early 2027, according to InfoQ and the htmx team’s announcement.
- The htmx team provides a command-line upgrade checker to help developers identify inheritance and renamed-attribute issues when migrating, according to InfoQ.
What We Don’t Know
- Neither source detailed the full reasoning behind skipping version 3 and jumping directly from the 2.x line to 4.0, beyond confirming the jump was deliberate, according to InfoQ.
- It is not yet clear what benchmarks or metrics, if any, the project will use to decide when 4.0 replaces 2.x as npm’s default “latest” tag beyond the general early-2027 target, according to the htmx team’s announcement.