This module enhances Drupal's core integration of HTMX, a library that allows developers to access AJAX, CSS transitions, and more directly through HTML attributes. It provides extra tools and support for using HTMX to build modern user interfaces with simpler code compared to other JavaScript frameworks.
HTMX in Drupal Core!
HTMX was added as a dependency to Drupal on in 11.2 as part of the Replace AJAX API with HTMX community initiative. A full featured integration is now in Drupal 11.3.
This module will transition to provide extra tools and support for using the HTMX integration found in core.
htmx gives you access to AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, using attributes, so you can build modern user interfaces with the simplicity and power of hypertext
htmx is small (~14k min.gz’d), dependency-free, extendable, IE11 compatible & has reduced code base sizes by 67% when compared with react
By removing these arbitrary constraints, htmx completes HTML as a hypertext
<button data-hx-get="/htmx/blocks/add/announce_block"
data-hx-target="#drupal-off-canvas-wrapper"
data-hx-select="#drupal-off-canvas-wrapper"
data-hx-swap="outerHTML ignoreTitle:true" class="button">
Add
</button>
The data-hx-get and data-hx-select attributes on this button tell htmx:
“When a user clicks on this button, issue an GET request to /htmx/blocks/add/announce_block, and select from the response the content with id drupal-off-canvas-wrapper”
The data-hx-target and data-hx-swap attributes tell htmx:
"Replace the existing content with id drupal-off-canvas-wrapper with the selected content."
Watch a recent session on HTMX in Drupal
For developers
We provide an easy developer experience in a fully documented class for assembling your HTMX attributes. Here's how we built the render array for the button described above:
$row['operations']['data'] = [
'#type' => 'button',
'#value' => 'Add',
'#attributes' => [
'class' => ['button'],
],
];
$htmxAddButton = new HtmxAttribute($row['operations']['data']['#attributes']);
$htmxAddButton->get(Url::fromRoute('entity.htmx_block.add_form', ['plugin_id' => $plugin_id]))
->target('#drupal-off-canvas-wrapper')
->select('#drupal-off-canvas-wrapper')
->swap('outerHTML ignoreTitle:true');
$row['operations']['data']['#attributes'] = $htmxAddButton->toArray();
Read about an admin interface we built in Drupal for a more in-depth introduction.
Full documentation is available in our documentation site and also included in the docs directory of the module.
Why do I want this over react or vue js?
Why you want to use htmx? Read this article about the "Rule of Least Power".
Hypermedia
Hypermedia is the basic architecture of the web. Learn more about this foundation and how HTMX aligns the hypermedia capabilities of HTML with HTTP in Hypermedia Systems
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
1 tracked project depends on this one
- Views Table Row Pinning and Flagging 24 sites
Activity
Release Timeline
Releases
| Version | Type | Core | Notes | Release date | |
|---|---|---|---|---|---|
| 2.0.0 | Stable | 11 | Use with core 11.3-11.5 | Aug 27, 2026 | |
| 2.0.0-rc1 | Pre-release | 11 | Final check before a full 2.0 | Apr 30, 2026 | |
| 2.0.0-beta2 | Pre-release | 11 | Version for use with Drupal 11.3 | Jan 9, 2026 | |
| 2.0.0-beta1 | Pre-release | 11 | Version for use with Drupal 11.3 | Jan 9, 2026 | |
| 2.x-dev | Dev | 11 | Drupal 11.3 compatible branch | Jan 9, 2026 | |
| 1.5.2 | Stable | 11 | Moves htmx debug library to the debug submodule | Dec 11, 2025 | |
| 1.5.1 | Stable | 11 | Properly handle htmx/drupal library deprecation | Nov 26, 2025 | |
| 1.6.x-dev | Dev | 11 | Moving to supporting tools and add-ons | Oct 23, 2025 | |
| 1.5.0 | Stable | 11 | Use with Drupal 11.2 | Aug 30, 2025 | |
| 1.5.0-beta1 | Pre-release | 11 | First test release of 1.5.x | Aug 7, 2025 | |
| 1.4.3 | Stable | 10–11 | Jul 20, 2025 | ||
| 1.5.x-dev | Dev | 11 | Requires D11.2+ | Jun 14, 2025 | |
| 1.4.2 | Stable | 10–11 | Bugfix on the toolbar feature | Jun 14, 2025 | |
| 1.4.1 | Stable | 10–11 | Minor bugfix to HTMX blocks | Mar 28, 2025 | |
| 1.4.0 | Stable | 10–11 | HTMX response headers are now supported. | Feb 15, 2025 | |
| 1.4.0-beta4 | Pre-release | 10–11 | Easier to setup debugging | Jan 15, 2025 | |
| 1.4.0-beta3 | Pre-release | 10–11 | HTMX library v2.0.4 | Dec 17, 2024 | |
| 1.3.5 | Stable | 10–11 | HTMX library v2.0.4 | Dec 17, 2024 | |
| 1.4.0-beta2 | Pre-release | 10–11 | Fix to manage empty values in HtmxLocationResponseData | Dec 3, 2024 | |
| 1.4.0-beta1 | Pre-release | 10–11 | Testing support for HTMX response headers | Dec 1, 2024 | |
| 1.4.x-dev | Dev | 10–11 | Dev branch for 1.4 series | Nov 26, 2024 | |
| 1.3.4 | Stable | 10–11 | Improves HX request headers for Drupal | Nov 25, 2024 | |
| 1.3.3 | Stable | 10–11 | Improve push-url by moving libraries return value to header | Nov 15, 2024 | |
| 1.3.2 | Stable | 10–11 | HTMX v2.0.3 | Oct 11, 2024 | |
| 1.3.1 | Stable | 10–11 | Fixes CSS bug in htmx mini pager | Oct 5, 2024 |