htmx 4.0 is under construction — migration guide

htmx:after:history:push

After a push state action

The htmx:after:history:push event fires specifically after a history.pushState() operation (creates new history entry).

When It Fires

After a new history entry is pushed, allowing forward/back navigation to this point.

Event Detail

  • path - The path that was pushed into history

Example

htmx.on('htmx:after:history:push', (evt) => { console.log('Pushed to history:', evt.detail.path); // Track navigation in analytics });

This creates a new entry in the browser’s history stack.