<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/htmx-4-is-here-cqjkqn1yz" -->

---
title: HTMX 4 is here | daily.dev
description: HTMX 4.0.0 was released on August 28, 2026, as a major update that switches internal networking from XMLHttpRequest to the native fetch API. Attribute...
canonical: https://daily.dev/posts/htmx-4-is-here-cqjkqn1yz
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: HTMX 4 is here | daily.dev
og:description: HTMX 4.0.0 was released on August 28, 2026, as a major update that switches internal networking from XMLHttpRequest to the native fetch API. Attribute...
og:url: https://daily.dev/posts/htmx-4-is-here-cqjkqn1yz
og:image: https://api.daily.dev/og/posts/CqJkqn1yz.png
og:image:alt: HTMX 4 is here
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# HTMX 4 is here

**[Flavio Copes](https://daily.dev/sources/flaviocopes)** · 5 min read · 1 upvotes · 0 comments

## Summary

HTMX 4.0.0 was released on August 28, 2026, as a major update that switches internal networking from XMLHttpRequest to the native fetch API. Attribute inheritance is no longer implicit and now requires the explicit :inherited suffix. Event names shift to a consistent htmx:phase:action pattern, history navigation now re-fetches pages instead of restoring localStorage DOM snapshots, and error responses (4xx/5xx) are swapped by default instead of being ignored. New features include built-in innerMorph/outerMorph swaps for preserving DOM state, multi-target updates via <hx-partial>, and a new event-based extension system including an htmx-2-compat extension for gradual migration and an official upgrade-check CLI tool. HTMX 2 remains supported and stays the npm 'latest' tag until early 2027.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://flaviocopes.com/htmx-4>

## Questions this post answers

### What changed between HTMX 2 and HTMX 4 regarding attribute inheritance?

In HTMX 2, attributes like hx-confirm placed on a parent element automatically applied to child elements. In HTMX 4, that inheritance is no longer implicit; developers must add the :inherited suffix, as in hx-confirm:inherited, to make a parent's attribute apply to its children. This is considered the biggest change developers face when upgrading an existing application.

_Track breaking changes like this one on daily.dev before they bite your htmx upgrade._

### Does HTMX 4 swap error responses like a 422 or 500 into the DOM by default?

Yes, HTMX 4 swaps every response by default except status codes 204 and 304, including 4xx and 5xx errors. HTMX 2 did not swap error responses by default. This is useful for validation HTML returned with a 422 status, but existing apps that return a full error page could see it rendered inside a small target unexpectedly; hx-status lets you set per-status targets or swap behavior.

_Compare framework defaults like this before they break production on daily.dev._

### How can I upgrade an existing HTMX 2 application to HTMX 4 safely?

Run the official upgrade checker with npx htmx.org@4 upgrade-check -- ./src, which requires Python 3 and detects inherited attributes, old event names, removed attributes, and old API calls. Then make inheritance explicit, rename event listeners to the new htmx:phase:action format, and review 4xx/5xx HTML responses. The htmx-2-compat extension restores old defaults for a gradual migration, and HTMX 2 stays npm's 'latest' tag until early 2027.

_Follow migration guides like this on daily.dev when planning your next framework upgrade._

## Similar posts on daily.dev

- [HTMX 4.0: Hypermedia finds a new gear](https://daily.dev/posts/htmx-4-0-hypermedia-finds-a-new-gear-swv18ajzs) · InfoWorld · 118 upvotes · 4 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#astro](https://daily.dev/tags/astro), [#htmx](https://daily.dev/tags/htmx), [#alpinejs](https://daily.dev/tags/alpinejs)

[View this post on daily.dev](https://daily.dev/posts/htmx-4-is-here-cqjkqn1yz)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"HTMX 4 is here","url":"https://daily.dev/posts/htmx-4-is-here-cqjkqn1yz","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/htmx-4-is-here-cqjkqn1yz"},"datePublished":"2026-08-29T07:19:48.055Z","dateModified":"2026-09-13T21:25:00.564Z","description":"HTMX 4.0.0 was released on August 28, 2026, as a major update that switches internal networking from XMLHttpRequest to the native fetch API. Attribute...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0a0111a090aaced8a57edc2bae4e38a2?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0a0111a090aaced8a57edc2bae4e38a2?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Flavio Copes","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Flavio Copes","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/1f2dbd275797411bbd37bfdaaf0951a9","url":"https://daily.dev/sources/flaviocopes"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/htmx-4-is-here-cqjkqn1yz","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,astro,htmx,alpinejs","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Flavio Copes","item":"https://daily.dev/sources/flaviocopes"},{"@type":"ListItem","position":3,"name":"HTMX 4 is here"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/htmx-4-is-here-cqjkqn1yz#faq","mainEntity":[{"@type":"Question","name":"What changed between HTMX 2 and HTMX 4 regarding attribute inheritance?","acceptedAnswer":{"@type":"Answer","text":"In HTMX 2, attributes like hx-confirm placed on a parent element automatically applied to child elements. In HTMX 4, that inheritance is no longer implicit; developers must add the :inherited suffix, as in hx-confirm:inherited, to make a parent's attribute apply to its children. This is considered the biggest change developers face when upgrading an existing application. Track breaking changes like this one on daily.dev before they bite your htmx upgrade."}},{"@type":"Question","name":"Does HTMX 4 swap error responses like a 422 or 500 into the DOM by default?","acceptedAnswer":{"@type":"Answer","text":"Yes, HTMX 4 swaps every response by default except status codes 204 and 304, including 4xx and 5xx errors. HTMX 2 did not swap error responses by default. This is useful for validation HTML returned with a 422 status, but existing apps that return a full error page could see it rendered inside a small target unexpectedly; hx-status lets you set per-status targets or swap behavior. Compare framework defaults like this before they break production on daily.dev."}},{"@type":"Question","name":"How can I upgrade an existing HTMX 2 application to HTMX 4 safely?","acceptedAnswer":{"@type":"Answer","text":"Run the official upgrade checker with npx htmx.org@4 upgrade-check -- ./src, which requires Python 3 and detects inherited attributes, old event names, removed attributes, and old API calls. Then make inheritance explicit, rename event listeners to the new htmx:phase:action format, and review 4xx/5xx HTML responses. The htmx-2-compat extension restores old defaults for a gradual migration, and HTMX 2 stays npm's 'latest' tag until early 2027. Follow migration guides like this on daily.dev when planning your next framework upgrade."}}]}
```

