htmx 4.0 is under construction — migration guide

Alpine.js Compatibility

Compatibility layer for using htmx with Alpine.js

The alpine-compat extension provides compatibility between htmx and Alpine.js, ensuring that Alpine components work correctly when htmx swaps new content into the DOM.

Installing

<script src="/path/to/htmx.js"></script> <script src="/path/to/ext/hx-alpine-compat.js"></script> <script defer src="/path/to/alpine.js"></script>

Usage

Once loaded, the extension automatically initializes Alpine.js components in content that htmx swaps into the page. Without this extension, Alpine components in dynamically swapped content would not be initialized.