Use hx-get/post/swap/trigger for server-driven UIs, implement out-of-band swaps, and understand HTMX's hypermedia architectural philosophy.
0 / 5 completed
1 / 5
What does the hx-get attribute do in HTMX?
hx-get: HTMX's core model is that server endpoints return HTML fragments, not JSON. The browser receives HTML and swaps it into place without JavaScript serialisation. This restores the hypermedia architecture of the early web — the server is the source of truth for UI state, and the client requests rendered HTML on each interaction.
2 / 5
What does the hx-swap attribute control in HTMX?
hx-swap:hx-swap="afterbegin" prepends new items to a list (useful for adding new items at the top). hx-swap="outerHTML" replaces the triggering element entirely (useful for inline editing that replaces a display element with a form). hx-swap="delete" removes the target after the request completes (useful for delete actions).
3 / 5
What does the hx-trigger attribute configure and what non-standard triggers does HTMX support?
hx-trigger:hx-trigger="keyup delay:500ms changed" on a search input debounces keystrokes and only fires if the value changed — a search-as-you-type pattern with two attributes. hx-trigger="revealed" enables infinite scroll. hx-trigger="every 5s" polls an endpoint for live updates, replacing setInterval.
4 / 5
What is the HTMX out-of-band swap pattern used for?
Out-of-band swap: a form submit returns the new list item HTML (swapped into the list) plus <span id="count" hx-swap-oob="true">42 items</span> — the count badge in the header is updated in the same response. This enables multi-target updates from a single request without JavaScript coordination, preserving the hypermedia model.
5 / 5
What is the architectural philosophy of HTMX-driven SPA patterns compared to React/Vue SPAs?
HTMX philosophy: React SPAs move UI logic to the client (state machines, API calls, rendering). HTMX keeps UI logic on the server — a Django/Rails/Go template renders the exact HTML the user sees. This simplifies the architecture (one language, one server, no client state) at the cost of server round-trips for every interaction and less snappy offline behaviour.