A simple cross-fade between pages used to need a JavaScript router.
@view-transition { navigation: auto; }
::view-transition-old(root) { animation-duration: .2s; }
::view-transition-new(root) { animation-duration: .2s; }
With this at-rule on both pages, a browser that supports cross-document view transitions animates the switch between them, a fade by default. Chrome and Edge support it since version 126 and Safari since 18.2. Firefox support is still partial, and MDN marks the feature as limited availability. Both pages must be on the same origin. The two pseudo-elements adjust the duration of the old and new snapshot. Other browsers just navigate as usual, so it works as an enhancement. Wrap the animation rules in a prefers-reduced-motion check for visitors who want less movement.
Further reading: MDN: @view-transition