htmx 4.0 is under construction — migration guide

htmx:before:viewTransition

Before View Transition API starts

The htmx:before:viewTransition event fires before a View Transition starts (if browser supports View Transitions API and htmx.config.transitions is true).

When It Fires

Before the swap operation begins its view transition animation.

Event Detail

  • task - Transition callback function

Example

htmx.on('htmx:before:viewTransition', (evt) => { console.log('Starting view transition'); // Customize transition behavior });

Cancel this event to skip the view transition for this swap.