htmx adds AJAX capabilities directly to HTML elements. Servers return HTML fragments. No JavaScript build step required. Progressive enhancement keeps sites accessible.
Core Attributes
hx-get and hx-post make requests. hx-target specifies where to place responses. hx-trigger controls when requests fire. hx-swap determines how content updates.
- Use hx-trigger for custom event handling
- Configure hx-swap for different update behaviors
- Implement hx-indicator for loading states
- Use hx-push-url for history management
- Combine with server-side templates
When to Use htmx
htmx suits content-focused applications. Server-rendered teams avoid JavaScript complexity. Progressive enhancement requirements fit naturally. Complex client state may need traditional SPAs.