Debian Codegraph @

www/src/content/reference/03-events/19-htmx-after-history-update.md

raw symbols SCIP
1 ---
2 title: "htmx:after:history:update"
3 description: "After browser history is updated"
4 ---
5
6 The `htmx:after:history:update` event fires after htmx has updated the browser history state.
7
8 ## When It Fires
9
10 After `history.pushState()` or `history.replaceState()` completes.
11
12 ## Event Detail
13
14 - `history` - Object with `type` ("push" or "replace") and `path`
15 - `sourceElement` - Element that triggered the navigation
16 - `response` - Response object
17
18 ## Example
19
20 ```javascript
21 htmx.on('htmx:after:history:update', (evt) => {
22 console.log('History updated to:', evt.detail.history.path);
23 // Update analytics, breadcrumbs, etc.
24 });
25 ```
26
27 The URL bar now reflects the new path.