Document: startViewTransition() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The startViewTransition() method of the Document interface starts a new same-document (SPA) view transition and returns a ViewTransition object to represent it.

When startViewTransition() is invoked, a sequence of steps is followed as explained in The view transition process.

Syntax

js
startViewTransition()
startViewTransition(updateCallback)

Parameters

updateCallback Optional

An optional callback function typically invoked to update the DOM during the SPA view transition process, which returns a Promise. The callback is invoked once the API has taken a snapshot of the current page. When the promise returned by the callback fulfills, the view transition begins in the next frame. If the promise returned by the callback rejects, the transition is abandoned.

Return value

A ViewTransition object instance.

Examples

Basic usage

Specifications

Specification
CSS View Transitions Module Level 1
# dom-document-startviewtransition
CSS View Transitions Module Level 2
# dom-document-startviewtransition

Browser compatibility

See also