DEV Community

Alex Spinov
Alex Spinov

Posted on

htmx Has a Free API You Should Know About

htmx gives you access to AJAX, CSS Transitions, WebSockets, and Server Sent Events directly in HTML — no JavaScript needed. It makes building dynamic web apps as simple as writing HTML attributes.

Why htmx is Taking Over

A Django developer was adding React to handle simple dynamic UI — click a button, load new content. With htmx, they replaced 500 lines of React + API code with 3 HTML attributes.

Key Features:

  • AJAX from HTML — Send requests with HTML attributes
  • Any Element — Not just forms and links, any element can trigger requests
  • Partial Updates — Swap any part of the page without full reload
  • CSS Transitions — Smooth animations on content changes
  • WebSockets & SSE — Real-time updates from HTML

Quick Start

<script src="https://unpkg.com/htmx.org@2"></script>
Enter fullscreen mode Exit fullscreen mode

Click to Load

<button hx-get="/api/users" hx-target="#user-list" hx-swap="innerHTML">
  Load Users
</button>
<div id="user-list"></div>
Enter fullscreen mode Exit fullscreen mode

Inline Editing

<div hx-get="/edit/1" hx-trigger="click" hx-swap="outerHTML">
  Click to edit this text
</div>
Enter fullscreen mode Exit fullscreen mode

Infinite Scroll

<tr hx-get="/contacts?page=2" 
    hx-trigger="revealed" 
    hx-swap="afterend">
  <td>Loading...</td>
</tr>
Enter fullscreen mode Exit fullscreen mode

Why Choose htmx

  1. No build step — just add a script tag
  2. Server-driven — works with any backend language
  3. Tiny — 14KB minified and gzipped
  4. Progressive enhancement — works without JavaScript

Check out htmx docs to get started.


Need web scraping? Check out my Apify actors or email spinov001@gmail.com for custom solutions.

Top comments (0)