The htmx.config object holds the current htmx configuration. You can modify it in JavaScript or set values using a <meta> tag.

Configure via Meta Tag

Set config values with HCON:

<meta name="htmx-config" content="defaultSwap:outerHTML defaultTimeout:5000">

Or JSON:

<meta name="htmx-config" content='{"defaultSwap":"outerHTML","defaultTimeout":5000}'>

Configure via JavaScript

Modify config values directly:

htmx.config.defaultSwap = 'outerHTML'; htmx.config.defaultTimeout = 5000;

Available Options

OptionDefaultDescription
logAllfalseLog all htmx events
prefix"data-hx-"Secondary attribute prefix recognized alongside hx-
metaCharacterundefinedCharacter used instead of : in attribute names
transitionsfalseEnable view transitions
historytrueEnable history support
mode"same-origin"Request mode for fetch()
defaultSwap"innerHTML"Default swap style
defaultSwapEmptyundefinedSwap empty main content unless an <hx-partial> was extracted
defaultFocusScrollfalseScroll to a focused element after swapping
defaultSettleDelay1Delay before settling in milliseconds
indicatorClass"htmx-indicator"CSS class for indicators
requestClass"htmx-request"CSS class during requests
includeIndicatorCSStrueInclude default indicator CSS
defaultTimeout60000Request timeout in milliseconds
extensions""Extensions to load
morphIgnore["data-htmx-powered"]Attributes to ignore during morphing
morphSkip"[hx-morph-skip]"Elements to skip while morphing
morphSkipChildren"[hx-morph-skip-children]"Elements whose children are not morphed
morphScanLimit10Siblings scanned while matching elements
noSwap[204, 304]HTTP status codes that skip swaps
implicitInheritancefalseEnable implicit attribute inheritance
inlineScriptNonceundefinedNonce added to inline scripts

See Also