React is the most popular frontend framework. Htmx is a counter-movement: add interactivity to server-rendered HTML without writing JavaScript. They solve the same problem differently.
How Each Works
Htmx
Server renders HTML. Htmx attributes on HTML elements trigger HTTP requests and swap content:
<button hx-get="/api/users" hx-target="#user-list" hx-swap="innerHTML">
Load Users
</button>
<div id="user-list"><!-- users appear here --></div>
Clicking the button sends a GET request to /api/users. The server returns HTML. Htmx swaps it into #user-list. No JavaScript written.
React
JavaScript renders a virtual DOM. State changes trigger re-renders:
function UserList() {
const [users, setUsers] = useState([])
const loadUsers = async () => {
const res = await fetch('/api/users')
setUsers(await res.json())
}
return (
<>
<button onClick={loadUsers}>Load Users</button>
<div>{users.map(u => <User key={u.id} {...u} />)}</div>
</>
)
}
Comparison
| Factor | Htmx | React |
|---|---|---|
| Bundle size | 14 KB | 45+ KB (React + ReactDOM) |
| JavaScript written | None (HTML attributes) | Everything is JS/TSX |
| Server requirements | Any server that returns HTML | API that returns JSON |
| Learning curve | 30 minutes | 2-4 weeks |
| Complex state management | Difficult | Natural (useState, context, etc.) |
| Offline support | No | Possible (service workers) |
| Real-time updates | WebSocket support | State management + WebSocket |
| SEO | Perfect (server-rendered HTML) | Requires SSR/SSG |
| Animation | CSS transitions | Framer Motion, GSAP |
| Component reuse | Server-side partials/templates | Client-side components |
| Testing | Integration tests (HTTP) | Unit + integration + E2E |
| Ecosystem | Small | Massive |
When Htmx Wins
- CRUD applications (admin panels, data management)
- Server-rendered applications (Django, Rails, Laravel, Go)
- Progressive enhancement of existing server-rendered sites
- Small teams without JavaScript expertise
- Content-heavy sites needing minor interactivity
- Simple interactive features (search, filtering, modals)
When React Wins
- Complex UIs (dashboards, interactive editors, drag-and-drop)
- Real-time applications (chat, collaboration, live dashboards)
- Rich animations and transitions
- Offline-capable applications
- Mobile apps (React Native)
- Large-scale applications with complex state
Our Position
We build with React (Next.js) because our projects typically require the interactivity, component composition, and ecosystem that React provides. Htmx is excellent for adding interactivity to server-rendered sites, but for the web applications we build, React is the right tool.
Contact us to discuss your project requirements.