Skip to main content

useViewTransitionState

Returns true when there is an active View Transition to the specified location. This can be used to apply finer-grained styles to elements to further customize the view transition.

Parameters

To
required
The location to check for an active View Transition. Can be a string path or a partial Path object with pathname, search, and hash.
object
"route" | "path"
default:"\"route\""
The relative routing type to use when resolving the to location:
  • "route" (default) - Relative to the route hierarchy
  • "path" - Relative to the URL path segments

Return Value

boolean
true if there is an active View Transition to the specified location, otherwise false.

Type Declaration

Usage Examples

Animated List Items

Conditional Transition Styles

Multiple Transition Elements

Common Patterns

Shared Element Transitions

Dynamic Transition Names

Back Navigation Transitions

CSS Integration

Defining View Transitions

Complex Transitions

Requirements

  1. View transitions must be enabled via the viewTransition prop on navigation:
  2. Browser support - View Transitions API is not supported in all browsers
  3. Must be used within RouterProvider from react-router-dom

Browser Support

View Transitions are a modern web API with limited browser support. Check Can I Use for current browser compatibility. For unsupported browsers, the transition simply won’t occur, and navigation will work normally.

Notes

  • Available in Framework and Data modes only
  • Must be used within react-router-dom’s RouterProvider (not the one from react-router)
  • Returns true for both forward and backward transitions to the specified location
  • The viewTransitionName CSS property must be set for transitions to work
  • Each viewTransitionName should be unique within the document
  • Transitions work bidirectionally (going to and coming from the location)