← All open source projects

htmx

bigskysoftware/htmx

htmx is a JavaScript library that adds AJAX, WebSocket, SSE, and partial HTML swaps directly through markup attributes.

Forks 1,601
Language JavaScript
License NOASSERTION
Synced 2026-06-10

What it is

htmx is a library for people who like the idea that the server already knows how to return HTML, and an interface does not need to become a large client application for every interactive detail. It adds `hx-*` attributes to markup, letting any element send an HTTP request, receive an HTML fragment, and replace part of the page.

The project grew out of intercooler.js and became a visible voice in the return to hypermedia-style interfaces. Its motivation is concrete: why should only links and forms send requests, why should only `click` and `submit` trigger them, and why must the response replace the entire screen? htmx removes those limits while keeping HTML as the main interaction format.

What is inside the repository

Inside is a small dependency-free JavaScript library, documentation, extensions, and tests. It works with AJAX, CSS transitions, WebSocket, Server-Sent Events, and different DOM swap strategies. The important part is the model: the server returns ready markup and the client inserts it into the right place.

Button with partial HTML replacement

This example shows the core htmx pattern: the button sends a `POST` request and the HTML response replaces the button itself. No separate client handler is needed, and state can remain on the server.

Language: HTML
<button hx-post="/clicked" hx-swap="outerHTML">
  Click
</button>

Where it is useful

htmx fits admin panels, account pages, forms, filters, tables, comments, and interfaces where the server model is already strong. It is especially pleasant with Laravel, Rails, Django, Phoenix, and other frameworks that can render HTML fragments easily.

Strengths and limits

The strength of htmx is simplicity and honest architecture: less client state, less build machinery, and less code for basic interactivity. The limit is also clear: complex offline apps, graphical editors, and interfaces with heavy local state may need React, Vue, Svelte, or another client layer.