Spec-Zone.ru › htmx

htmx.config.history

Controls htmx browser history management

The htmx.config.history option controls browser history during navigation.

Default: true

Value Behavior
true htmx pushes URLs into history and restores them on back/forward by fetching the page via GET and swapping innerHTML on body.
false htmx does not push URLs into history or intercept back/forward navigation.
"reload" htmx pushes URLs into history normally, but on back/forward navigation calls location.reload() instead of attempting to restore via ajax.

Examples

// Disable history entirely
htmx.config.history = false;

// Push URLs, but use full page reload on back/forward
htmx.config.history = "reload";
<meta name="htmx-config" content='{"history":false}'>
<meta name="htmx-config" content='{"history":"reload"}'>

The "reload" option is useful when pages use client-side state (e.g. from hyperscript or Alpine.js) that cannot be reconstructed from a plain innerHTML swap.

Licensed under the Zero-Clause BSD License.
https://four.htmx.org/reference/config/htmx-config-history/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API