htmx is a small JavaScript library that lets you build interactive web pages using only HTML attributes. Click a button, and part of the page updates — no JavaScript framework, no build step, no state management. If you like HTML and you are tired of reaching for a heavy framework for simple interactions, htmx is worth learning.
The idea is that HTML was always meant to be interactive, but the browser only gave you two tools: links and forms, both of which reload the whole page. htmx extends HTML so any element can make a request and swap part of the page with the response. A button that loads more items looks like this:
<script src="https://unpkg.com/htmx.org@1.9.12"></script>
<button hx-get="/more-items" hx-target="#results" hx-swap="beforeend">
Load more
</button>
<div id="results"></div>
Click the button, and htmx fetches /more-items from your server and appends the response to #results. No JavaScript written, no framework installed, no build step. The server returns plain HTML, and htmx puts it in the right place. That is the whole model — and it is how the web worked before single-page apps took over.
htmx is not a framework. It is a 14KB library that you add to a page with one script tag. It works with any backend — Django, Rails, Go, Node, PHP — because the server just returns HTML. That makes it a good fit for server-rendered apps, for prototypes, and for teams that want interactivity without a JavaScript build pipeline.
The limits are honest. htmx is not for complex client-side apps with lots of local state — a spreadsheet, a drawing tool, or a real-time game still needs real JavaScript. Its community is smaller than React's, so finding answers takes longer. And if your team already knows a framework well, switching to htmx for a complex app is a step backwards.
Start today with one step: add the script tag to a plain HTML page, write a button like the one above, and make your server return a small HTML fragment. When the page updates without a reload and without a line of JavaScript, you will see why htmx has a devoted following.
Top comments (0)