Skip to content

useViewTransition ​

Returns the view transition in flight, if any.

ts
import { useViewTransition } from '@kitbag/router'

const viewTransition = useViewTransition()

onMounted(async () => {
  await viewTransition.transition?.finished

  heading.value?.focus()
})

The returned object is reactive, so read its properties where they are used rather than destructuring them.

PropertyDescription
isTransitioningTrue from when a navigation is decided to transition until its animation finishes
toThe route being navigated to
fromThe route being left
typesThe types the transition runs with
transitionThe browser's ViewTransition, once started

TIP

Register your router to get the proper types for to and from when using this composable.