document.startViewTransition() is an instance method that starts a same-document (SPA), document-scoped view transition and returns a ViewTransition object (see MDN Document: startViewTransition()). Learn the MDN color demo, updateCallback / options.types, CSS ::view-transition-group, how it compares to Element.startViewTransition(), and five try-it labs.
01
Kind
Instance method
02
Scope
Document / SPA
03
Returns
ViewTransition
04
Args
callback | options
05
CSS
::view-transition-*
06
Status
Baseline 2025
Fundamentals
Introduction
Single-page apps often swap content with JavaScript. Without help, those updates feel abrupt. The View Transition API lets the browser snapshot the old UI, apply your DOM update, then animate to the new UI.
MDN: document.startViewTransition() starts a same-document, document-scoped transition and returns a ViewTransition you can await or skip. Pair it with CSS such as ::view-transition-group(root) to control timing and style.
💡
Think: “Snapshot → update DOM → animate”
1) Feature-detect document.startViewTransition 2) Call it with a function that changes the DOM 3) Style the transition with ::view-transition-* CSS 4) If unsupported, just run the DOM update (MDN fallback)
updateCallbackOptional — callback invoked to update the DOM during the SPA view transition process. It returns a Promise. Invoked once the API has taken a snapshot of the current page. When the promise fulfills, the view transition begins in the next frame. If it rejects, the transition is abandoned (MDN).
optionsOptional — object that may include:
update — same as updateCallback; defaults to null (MDN).
types — array of strings applied as view transition types for selective CSS/JS; defaults to [] (MDN).
Return value
A ViewTransition object instance (MDN).
MDN basic pattern
JavaScript
const changeColor = () => {
// Fallback for browsers that don't support View Transitions:
if (!document.startViewTransition) {
updateColor();
return;
}
// With View Transitions:
const transition = document.startViewTransition(() => {
updateColor();
});
};
Compare
⚖️ Document vs Element startViewTransition
document.startViewTransition()
element.startViewTransition()
Scope
Entire document (SPA) (MDN)
One element subtree (MDN)
Best for
Full-page content swaps
Widgets, cards, slideshows
Rest of page
Document-scoped transition
Can stay interactive (MDN)
Returns
ViewTransition
ViewTransition
MDN Document status
Baseline Newly available (Oct 2025)
Often Experimental / Limited on Element page
Cheat Sheet
⚡ Quick Reference
Goal
Code / note
Feature-detect
if (!document.startViewTransition) { /* fallback */ }
Theme update runs (types support may vary by browser)
How It Works
MDN notes some parts of the feature may have varying support — always feature-detect and keep a fallback.
Example 5 — Skip an in-flight transition
Jump straight to the end state when the user navigates again quickly.
JavaScript
let current = null;
function navigate(update) {
if (current) {
current.skipTransition();
}
if (!document.startViewTransition) {
update();
current = null;
return;
}
current = document.startViewTransition(update);
current.finished.finally(() => {
if (current && current.finished) current = null;
});
}
Document.startViewTransition() is Baseline Newly available on MDN (since October 2025). Some parts of this feature may have varying levels of support. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline Newly available
Document.startViewTransition()
Same-document SPA view transitions with a ViewTransition return value and CSS ::view-transition-* styling.
BaselineNewly available
Google Chrome111+
Yes
Microsoft Edge111+
Yes
Mozilla Firefox144+
Yes
Apple Safari18+
Yes
Opera97+
Yes
Internet ExplorerNot supported
No
startViewTransition()Newly available
Bottom line: Feature-detect document.startViewTransition, update the DOM in the callback, style with ::view-transition-*, and keep an instant fallback for older browsers.
Wrap Up
Conclusion
document.startViewTransition() is the document-scoped entry point for same-document view transitions: snapshot, update, animate. Feature-detect, style with view-transition CSS, and fall back to plain DOM updates when needed.
MDN: Document.startViewTransition() starts a new same-document (SPA), document-scoped view transition and returns a ViewTransition object to represent it.
No. MDN marks Document.startViewTransition() as Baseline Newly available (since October 2025). Some parts of the feature may have varying support. It is not Deprecated, Experimental, or Non-standard on the Document page.
A ViewTransition object instance (MDN).
Optional function invoked to update the DOM during the SPA view transition. It returns a Promise. The callback runs after a snapshot of the current page; when the promise fulfills, the transition begins in the next frame. If it rejects, the transition is abandoned (MDN).
Document.startViewTransition() is document-scoped (whole-page same-document transitions). Element.startViewTransition() scopes the transition to one element’s subtree so the rest of the page can stay interactive (MDN).
Yes. Always feature-detect. If document.startViewTransition is missing, update the DOM immediately without animation (MDN basic usage pattern).
Did you know?
Same-document view transitions became Baseline Newly available when Firefox 144 shipped support in October 2025 — completing the modern Chrome / Safari / Firefox set for document.startViewTransition(updateCallback).