Overview
Pick htmx when the interface is HTML pages with interactions that mean “send a request, swap a region”; pick React when the client holds state that changes faster than a server round trip. htmx is a dependency-free script of about 16 KB min.gz. As of 2026-10-01 htmx 4.0 (released August 2026) is published on npm under a non-latest tag while 2.x stays latest, with 4.0 expected to become latest in 2027, so pin the major version you choose.
Comparison
| Dimension | htmx | React |
|---|---|---|
| Model | Server returns HTML fragments; attributes trigger requests | Client components own state and render |
| State | Server and database | Client (hooks, stores, query cache) |
| Build step | None required | Required (Vite, Next.js) |
| Latency per interaction | Network round trip | Local, with optimistic updates |
| Offline and drag-and-drop | Poor fit | Strong fit |
| SEO and accessibility | HTML by default | Needs SSR or Server Components, plus discipline |
| Mobile reuse | Web only | React Native |
| Server stack | Any that renders HTML (Django, FastAPI, Rails, Go) | Any API, or Next.js |
Pick htmx when
Pick htmx for CRUD-shaped products where the server is the source of truth.
- Admin panels, internal tools, content sites, and multi-page apps where each page does one job.
- A backend-led team that wants no client bundler, API layer, or client cache to keep in sync.
- Forms and partial updates (search, pagination, inline edit) with
hx-get,hx-post, andhx-swap. - Use fastapi-vs-django or any server that returns HTML fragments.
Pick React when
Pick React for single-page product surfaces.
- Drag-and-drop boards, editors, virtualized grids, real-time collaboration, charts with local interaction.
- Offline or optimistic UI backed by tanstack-query-vs-swr.
- Code shared with React Native, or a dedicated frontend team and the React component ecosystem.
- If you want React with less client JavaScript, use Server Components; see server-vs-client-components.
Combine
Use htmx for the page shell and mount a React island where one screen needs rich state, or the reverse with islands in Astro (astro-islands). Moving a CRUD-shaped React SPA to htmx deletes the API layer and client state, but it is a rewrite; estimate by endpoints and screens, not lines of code.
FAQ
Can htmx replace React?
For CRUD-shaped apps where the server owns state, yes: admin panels, internal tools, content sites, and multi-page apps. Keep React for drag-and-drop, editors, real-time collaboration, offline use, or React Native reuse.
How big is htmx?
htmx is a dependency-free script of about 16 KB min.gz and needs no build step. React requires a build step such as Vite or Next.js.
Should I use htmx 4 or htmx 2?
As of 2026-10-01 htmx 4.0 is on npm under a non-latest tag while 2.x stays latest, with 4.0 expected to become latest in 2027. Pin the major version you choose.
Can I use htmx and React in the same app?
Yes; use htmx for the page shell and mount a React island where one screen needs rich state. Astro islands are the reverse arrangement.