History, errors, and enhancement
Boost links and forms
Enhance ordinary navigation and submission while preserving the original HTML behavior without JavaScript.
8 minute lesson
hx-boost intercepts ordinary links and forms while preserving their native fallback:
<main hx-boost="true">
<a href="/tasks">Tasks</a>
<form action="/search" method="get">
<input name="q" type="search">
<button>Search</button>
</form>
</main>
A boosted same-origin link sends a GET to its href, swaps the response into <body> with innerHTML by default, scrolls to the top, and pushes the URL into history. A boosted form uses its action and method, but does not push a URL unless you request that separately.
The server should return complete pages for boosted navigation. HTMX can update the document title and choose the body content, while direct navigation and JavaScript-disabled browsing receive the same useful response.
hx-boost is inherited. Set hx-boost="false" on a child that must keep normal navigation, such as a download or third-party flow. Only same-origin, non-anchor links are boosted.
Inspect HX-Boosted: true when the server needs rendering context, but never treat it as authorization. Test direct navigation, refresh, back, and forward after enabling boost on a region.
Lesson completed