Attributes33 attributes

Requests

hx-getIssues GET request to specified URL
hx-postIssues POST request to specified URL
hx-putIssues PUT request to specified URL
hx-patchIssues PATCH request to specified URL
hx-deleteIssues DELETE request to specified URL

Request Control

hx-triggerControls when element issues requests
hx-swapControls how response is inserted
hx-targetControls where response is inserted
hx-selectControls which response part is inserted
hx-swap-oobMarks response elements to swap into page by ID
hx-select-oobPicks response elements to swap into page by ID
hx-confirmShows confirmation dialog before request

Scripting

hx-onRuns inline JavaScript when event fires

Data

hx-valsAdds values to request parameters
hx-includeIncludes additional element values in request
hx-headersAdds custom headers to request
hx-encodingSets request encoding type

History

hx-push-urlPushes URL into browser history
hx-replace-urlReplaces current URL in browser history
hx-history-eltMarks element to swap on history restore

Enhancements

hx-boostConverts links and forms to AJAX
hx-preloadPreloads content before user triggers request
hx-optimisticShows optimistic content during request

Advanced

hx-indicatorSpecifies loading indicator element
hx-statusHandles responses differently by status code
hx-syncSynchronizes requests between elements
hx-validateValidates before submitting request
hx-disableDisables elements during request
hx-ignoreDisables htmx processing for element
hx-preservePreserves element during swaps
hx-actionSpecifies URL to receive request
hx-methodSpecifies HTTP method for request
hx-configConfigures request behavior

Headers16 headers

Request

HX-RequestIndicates request was made by htmx
HX-Request-TypeIndicates partial or full page request
HX-Current-URLContains browser URL when request started
HX-SourceIdentifies element that triggered the request
HX-TargetIdentifies element that will receive response
HX-BoostedIndicates boosted navigation request
HX-History-Restore-RequestIndicates history navigation (back/forward)

Response

HX-TriggerTriggers client-side events with htmx.trigger()
HX-LocationNavigates with htmx.ajax()
HX-RedirectRedirects by setting location.href
HX-RefreshReloads page with location.reload()
HX-RetargetOverrides swap target from server
HX-ReswapOverrides swap style from server
HX-ReselectOverrides content selection from server
HX-Replace-UrlReplaces current URL in browser history
HX-Push-UrlPushes URL into browser history stack

Events31 events

Request Lifecycle

htmx:config:requestFires before request data is encoded
htmx:confirmFires before handling hx-confirm
htmx:before:requestFires immediately before fetch()
htmx:before:responseFires after fetch(), before response.text()
htmx:after:requestFires after response.text()
htmx:response:errorFires for HTTP status 400 or higher
htmx:before:swapFires before DOM update
htmx:before:settleFires after DOM insertion, before settle tasks
htmx:after:settleFires after settle tasks
htmx:after:swapFires after DOM update
htmx:finally:requestFires after lifecycle ends, including failures
htmx:errorFires after request or swap exception
htmx:abortAborts in-flight request

Elements

htmx:before:initFires before element initialization
htmx:after:initFires after element initialization
htmx:before:processFires before DOM node processing
htmx:after:processFires after DOM node processing
htmx:process:{type}Fires during registered template processing
htmx:after:implicitInheritanceFires after implicit inheritance
htmx:before:cleanupFires before element data removal
htmx:after:cleanupFires after element data removal
loadFires after element initialization

History

htmx:before:history:updateFires before browser history update
htmx:after:history:updateFires after browser history update
htmx:after:history:pushFires after history push
htmx:after:history:replaceFires after history replacement
htmx:before:history:restoreFires before history restoration

View Transitions

htmx:before:viewTransitionFires before view transition starts
htmx:after:viewTransitionFires after view transition completes

Triggers

intersectFires when element enters viewport
everyFires at each polling interval

Config24 config

Core

htmx.configConfigures htmx behavior globally
htmx.versionReports current htmx version (read-only)
htmx.config.prefixSets secondary attribute prefix
htmx.config.metaCharacterReplaces : in attribute modifiers
htmx.config.extensionsRestricts extension registration by name

Requests

htmx.config.defaultTimeoutSets default request timeout in ms
htmx.config.modeSets request mode for fetch()

Swaps

htmx.config.defaultSwapSets default swap style for responses
htmx.config.defaultSwapEmptyControls main swap when response body is empty
htmx.config.noSwapSets HTTP status codes that skip swap
htmx.config.transitionsEnables View Transitions API support
htmx.config.defaultSettleDelaySets swap-to-settle delay in ms
htmx.config.defaultFocusScrollScrolls to focused element after swap

Morphing

htmx.config.morphIgnorePreserves attribute prefixes during morphing
htmx.config.morphSkipSkips morphing for specific elements
htmx.config.morphSkipChildrenSkips morphing children of specific elements
htmx.config.morphScanLimitLimits siblings scanned during morph matching

Indicators

htmx.config.includeIndicatorCSSIncludes built-in loading indicator CSS
htmx.config.indicatorClassSets class hidden by built-in indicator CSS
htmx.config.requestClassSets class applied during requests

Behavior

htmx.config.historyControls htmx browser history management
htmx.config.implicitInheritanceEnables implicit attribute inheritance
htmx.config.inlineScriptNonceSets nonce on inline scripts generated by htmx
htmx.config.logAllLogs all htmx events to console

Methods11 methods

Requests

htmx.ajax()Issues an htmx request

DOM

htmx.find()Finds first matching element
htmx.findAll()Finds all matching elements
htmx.process()Processes htmx attributes on element
htmx.swap()Swaps HTML content

Events

htmx.on()Listens for htmx events
htmx.onLoad()Executes callback when elements load
htmx.trigger()Triggers custom events

Extensions

htmx.registerExtension()Registers htmx extension

Timing

htmx.parseInterval()Parses time intervals to milliseconds
htmx.timeout()Creates timeout Promise

Tags1 tags

<hx-partial>Targets multiple elements with one response