htmx 4.0 is under construction — migration guide

htmx:after:history:update

After browser history is updated

The htmx:after:history:update event fires after htmx has updated the browser history state.

When It Fires

After history.pushState() or history.replaceState() completes.

Event Detail

  • history - Object with type (“push” or “replace”) and path
  • sourceElement - Element that triggered the navigation
  • response - Response object

Example

htmx.on('htmx:after:history:update', (evt) => { console.log('History updated to:', evt.detail.history.path); // Update analytics, breadcrumbs, etc. });

The URL bar now reflects the new path.