<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/htmx-4-0-a-fetch-based-rewrite-built-in-morphing-swaps-and-explicit-attribute-inheritance-oyfu5ub5c" -->

---
title: htmx 4.0: a Fetch-Based Rewrite, Built-In Morphing...
description: htmx 4.0.0 has shipped, the first major release since 2.0 in 2024, skipping version 3 entirely. The library moved from XMLHttpRequest to the fetch() API,...
canonical: https://daily.dev/posts/htmx-4-0-a-fetch-based-rewrite-built-in-morphing-swaps-and-explicit-attribute-inheritance-oyfu5ub5c
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: htmx 4.0: a Fetch-Based Rewrite, Built-In Morphing Swaps, and Explicit Attribute Inheritance | daily.dev
og:description: htmx 4.0.0 has shipped, the first major release since 2.0 in 2024, skipping version 3 entirely. The library moved from XMLHttpRequest to the fetch() API,...
og:url: https://daily.dev/posts/htmx-4-0-a-fetch-based-rewrite-built-in-morphing-swaps-and-explicit-attribute-inheritance-oyfu5ub5c
og:image: https://api.daily.dev/og/posts/oyFU5Ub5c.png
og:image:alt: htmx 4.0: a Fetch-Based Rewrite, Built-In Morphing Swaps, and Explicit Attribute Inheritance
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.0: a Fetch-Based Rewrite, Built-In Morphing Swaps, and Explicit Attribute Inheritance

**[InfoQ](https://daily.dev/sources/infoq)** · 3 min read · 0 upvotes · 0 comments

## Summary

htmx 4.0.0 has shipped, the first major release since 2.0 in 2024, skipping version 3 entirely. The library moved from XMLHttpRequest to the fetch() API, enabling native streaming while keeping the script around 14KB. Notable additions include built-in morphing swaps via idiomorph for preserving DOM state like input focus, and a new hx-partial tag for updating multiple targets from one response. Attribute inheritance is now explicit, requiring an :inherited suffix, which can silently break things like CSRF headers passed to children. Event names are standardized to a htmx:phase:action pattern, and history snapshots now refetch pages instead of using localStorage. The release ships under npm's next tag, leaving 2.x as the default with indefinite support, and includes a CLI upgrade checker plus LLM-assisted upgrade guides.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.infoq.com/news/2026/09/htmx-4-released>

## Questions this post answers

### What breaks when upgrading from htmx 2.x to htmx 4.0?

Attribute inheritance becomes explicit, requiring an :inherited suffix on attributes like hx-headers or hx-confirm for them to reach child elements; without it, things like a CSRF token header silently stop being passed to children, causing the server to reject requests with a 403 while nothing looks visibly broken. Event names also change from htmx:afterRequest style to htmx:after:request, and hx-disable is renamed to hx-ignore.

_Track breaking changes like this before running an htmx upgrade on daily.dev._

### How do I upgrade to htmx 4.0 safely without breaking my templates?

Run the official command line checker, npx htmx.org@4.0.0 upgrade-check against a templates directory, which flags inheritance issues, renamed attributes, and old event names before they cause runtime failures. htmx 4.0 ships under npm's next tag rather than latest, so existing unversioned CDN links are not force-upgraded, and 2.x remains supported indefinitely, giving teams time to migrate deliberately.

_daily.dev helps developers planning a library migration stay ahead of htmx breaking changes._

### What is the new hx-partial tag in htmx 4.0 used for?

hx-partial lets a single server response cleanly update several different targets on a page, serving as a tidier alternative to htmx's older out-of-band swap mechanism. It pairs with built-in morphing swaps powered by the idiomorph library, which preserve DOM state such as input focus during updates, both introduced as part of the fetch()-based rewrite in htmx 4.0.

_Developers evaluating hypermedia tooling like htmx follow feature changes like this on daily.dev._

## 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), [#htmx](https://daily.dev/tags/htmx)

[View this post on daily.dev](https://daily.dev/posts/htmx-4-0-a-fetch-based-rewrite-built-in-morphing-swaps-and-explicit-attribute-inheritance-oyfu5ub5c)

```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.0: a Fetch-Based Rewrite, Built-In Morphing Swaps, and Explicit Attribute Inheritance","url":"https://daily.dev/posts/htmx-4-0-a-fetch-based-rewrite-built-in-morphing-swaps-and-explicit-attribute-inheritance-oyfu5ub5c","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/htmx-4-0-a-fetch-based-rewrite-built-in-morphing-swaps-and-explicit-attribute-inheritance-oyfu5ub5c"},"datePublished":"2026-09-18T09:46:04.346Z","dateModified":"2026-09-23T09:05:37.601Z","description":"htmx 4.0.0 has shipped, the first major release since 2.0 in 2024, skipping version 3 entirely. The library moved from XMLHttpRequest to the fetch() API,...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3bbb5f3067bf0b2e5bfe8d6276926e1f?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/3bbb5f3067bf0b2e5bfe8d6276926e1f?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"InfoQ","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":"InfoQ","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/afc3bced3e1e4b188dd9127017a60e0c","url":"https://daily.dev/sources/infoq"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/htmx-4-0-a-fetch-based-rewrite-built-in-morphing-swaps-and-explicit-attribute-inheritance-oyfu5ub5c","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,htmx","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"InfoQ","item":"https://daily.dev/sources/infoq"},{"@type":"ListItem","position":3,"name":"htmx 4.0: a Fetch-Based Rewrite, Built-In Morphing Swaps, and Explicit Attribute Inheritance"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/htmx-4-0-a-fetch-based-rewrite-built-in-morphing-swaps-and-explicit-attribute-inheritance-oyfu5ub5c#faq","mainEntity":[{"@type":"Question","name":"What breaks when upgrading from htmx 2.x to htmx 4.0?","acceptedAnswer":{"@type":"Answer","text":"Attribute inheritance becomes explicit, requiring an :inherited suffix on attributes like hx-headers or hx-confirm for them to reach child elements; without it, things like a CSRF token header silently stop being passed to children, causing the server to reject requests with a 403 while nothing looks visibly broken. Event names also change from htmx:afterRequest style to htmx:after:request, and hx-disable is renamed to hx-ignore. Track breaking changes like this before running an htmx upgrade on daily.dev."}},{"@type":"Question","name":"How do I upgrade to htmx 4.0 safely without breaking my templates?","acceptedAnswer":{"@type":"Answer","text":"Run the official command line checker, npx htmx.org@4.0.0 upgrade-check against a templates directory, which flags inheritance issues, renamed attributes, and old event names before they cause runtime failures. htmx 4.0 ships under npm's next tag rather than latest, so existing unversioned CDN links are not force-upgraded, and 2.x remains supported indefinitely, giving teams time to migrate deliberately. daily.dev helps developers planning a library migration stay ahead of htmx breaking changes."}},{"@type":"Question","name":"What is the new hx-partial tag in htmx 4.0 used for?","acceptedAnswer":{"@type":"Answer","text":"hx-partial lets a single server response cleanly update several different targets on a page, serving as a tidier alternative to htmx's older out-of-band swap mechanism. It pairs with built-in morphing swaps powered by the idiomorph library, which preserve DOM state such as input focus during updates, both introduced as part of the fetch()-based rewrite in htmx 4.0. Developers evaluating hypermedia tooling like htmx follow feature changes like this on daily.dev."}}]}
```

