Using htmx’s hx-get for Live Search Without Writing JavaScript
Learn how to add a live‑search box that fetches results with a single hx-get attribute, see the markup, and understand the trade‑offs of frequent requests.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Learn how to add a live‑search box that fetches results with a single hx-get attribute, see the markup, and understand the trade‑offs of frequent requests.
Learn how to add a button that fetches a server‑rendered snippet and swaps it into the page without a full reload, using htmx’s hx-get attribute.
Problem Statement After upgrading the htmx library, click interactions that previously relied on hx-boost no longer trigger requests. The page loads, but the console shows no network activity and the DOM does not update. Diagnostic Constraints • The application pins a specific htmx file via a CDN, using SRI where possible. • A prior build remains deployable;
When using htmx's hx-retry attribute on a form that issues a POST request to create a resource, the goal is to prevent duplicate writes if the initial request succeeds but htmx retries due to a transient network error. htmx currently re‑issues the exact same request without any built‑in mechanism to detect that the server already processed the operation, so
Unannounced failure states in an hx-swap workflow I am designing a form workflow that uses hx-post with hx-target and hx-swap to update a results fragment in place. The documented behavior is that htmx, by default, does not swap response content for 4xx and 5xx status codes (with version-sensitive exceptions such as 422), which means a failed request can pro
Background The htmx SSE extension maintains persistent server-sent event connections for real-time updates, but its reconnection behavior after browser tab restoration or network interruption relies on the browser's native EventSource implementation combined with htmx's reconnect configuration parameter. The core documentation does not formally specify recon
Goal: show a useful alert only once per successful request without creating notification spam. When an hx-trigger event fires a click or load, the same element may be swapped repeatedly by hx-swap, which replaces the target’s innerHTML and can remove or duplicate the alert container, causing missed or noisy messages. The precise uncertainty is whether htmx p
I am building a page where an htmx request targets a container that can be re-rendered by a separate part of the UI while the request is still in flight. The button uses hx-get with hx-target pointing at that container and hx-swap="innerHTML" . When the container is replaced in the DOM before the response returns, the update appears to vanish: no visible cha
When migrating a small application to htmx without downtime, the goal is to replace server‑rendered fragments incrementally while keeping the existing backend unchanged. htmx’s core HTML‑over‑the‑wire swap replaces a target element with the response body, but the documentation only specifies the default outerHTML behavior for overlapping hx‑triggered request