htmx interview question · Most asked
How does htmx compare with React or Vue?
Summary
React and Vue usually render HTML in the browser from JSON returned by an API, with state in JavaScript. htmx renders on the server and swaps HTML fragments, with state on the server. htmx means much less client code and no build step; frameworks are better for highly interactive, offline or multi-client UIs.
Longer Answer
With a SPA you write two applications: an API and a client that duplicates knowledge of how data is shown. With htmx you write one server-rendered app. The trade-off: every interaction that needs new data is a server round trip, and very rich client interactions (drag-and-drop editors, design tools) are awkward. Many products mix both: htmx pages with a framework "island" for one complex widget.
Key Points
- SPA: JSON + client rendering + client state.
- htmx: HTML fragments + server state.
- htmx: less code, no build.
- Frameworks: rich, offline, multi-client UIs.
Deep dive: htmx: Build Interactive Web Apps with HTML: Choosing htmx: Architecture Decisions
Explanation
What interviewers look for
A balanced comparison with concrete criteria, not hype.
Follow-up questions
- Which would you choose for an admin panel? For a whiteboard app?
More most-asked htmx questions
- What is htmx?
- What security risks are specific to htmx, and how do you mitigate them?
- What do hx-get, hx-post, hx-put, hx-patch and hx-delete do, and how are values sent?
- What is hx-target, and what relative selectors does it support?
- What swap styles does hx-swap support?
- How does hx-trigger work? Give examples of modifiers and special triggers.
- How do you handle form validation errors with htmx?
- Explain the htmx request lifecycle.