| 1 | --- |
| 2 | title: "htmx.config.history" |
| 3 | description: "Control htmx browser history management" |
| 4 | --- |
| 5 | |
| 6 | Controls how htmx manages browser history during navigation. |
| 7 | |
| 8 | **Default:** `true` |
| 9 | |
| 10 | | Value | Behavior | |
| 11 | |-------|----------| |
| 12 | | `true` | htmx pushes URLs into history and restores them on back/forward by fetching the page via `GET` and swapping `innerHTML` on `body`. | |
| 13 | | `false` | htmx does not push URLs into history or intercept back/forward navigation. | |
| 14 | | `"reload"` | htmx pushes URLs into history normally, but on back/forward navigation calls `location.reload()` instead of attempting to restore via ajax. | |
| 15 | |
| 16 | ## Examples |
| 17 | |
| 18 | ```javascript |
| 19 | // Disable history entirely |
| 20 | htmx.config.history = false; |
| 21 | |
| 22 | // Push URLs, but use full page reload on back/forward |
| 23 | htmx.config.history = "reload"; |
| 24 | ``` |
| 25 | |
| 26 | ```html |
| 27 | <meta name="htmx-config" content='{"history":false}'> |
| 28 | <meta name="htmx-config" content='{"history":"reload"}'> |
| 29 | ``` |
| 30 | |
| 31 | 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. |