JavaScript Document activeViewTransition Property

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Experimental
Instance property

What You’ll Learn

Document.activeViewTransition is a read-only instance property that returns the ViewTransition currently active on the document, or null if none is running. Learn why MDN recommends it over saving references, how it pairs with document.startViewTransition(), cross-document pagereveal / pageswap access, and five hands-on examples.

01

Kind

Read-only property

02

Returns

ViewTransition | null

03

Status

Experimental

04

Scope

Document-scoped VT

05

Start via

startViewTransition()

06

Also via

pagereveal / pageswap

Introduction

The View Transition API animates DOM updates smoothly. With document-scoped transitions you call document.startViewTransition(callback) to capture the old page state, run your DOM update, then animate to the new state.

Sometimes you start a transition in one place and need the same ViewTransition object elsewhere—to await finished, call skipTransition(), or check whether a transition is still running. MDN: document.activeViewTransition gives a consistent way to read the active transition without storing the return value yourself.

JavaScript
console.log(document.activeViewTransition); // null when idle (if supported)
💡
Beginner tip

You can also get a transition from document.startViewTransition() (same-document) or from event.viewTransition on pagereveal / pageswap (cross-document). activeViewTransition works in any context once a transition is active.

Related Document tutorials: activeElement, Document constructor. Compare with element-scoped Element.activeViewTransition.

Understanding the Property

MDN: the activeViewTransition read-only property of the Document interface returns a ViewTransition instance representing the view transition currently active on the document.

  • Read-only — you read it; you do not assign to it.
  • ValueViewTransition while active, otherwise null.
  • Experimental — Limited availability (not Baseline) on MDN.
  • Pair withdocument.startViewTransition() for same-document transitions.
  • Cross-document — also reachable while a navigation transition runs (via page events or this property).

📝 Syntax

JavaScript
document.activeViewTransition

Value

A ViewTransition, or null if the document has no active view transition.

MDN pattern

JavaScript
document.startViewTransition(() => {
  updateUI();
});

if (document.activeViewTransition) {
  console.log("A view transition is currently active");
}

document.activeViewTransition.finished.then(() => {
  console.log("View transition finished");
});

⚖️ Document vs Element scope

APIScopeTypical start
document.activeViewTransitionWhole document (same-document VT)document.startViewTransition(…)
element.activeViewTransitionThat element’s subtreeelement.startViewTransition(…)
event.viewTransitionCross-document navigationpagereveal / pageswap events

Document-scoped transitions are common for SPA route changes and full-page UI swaps. Element-scoped transitions suit cards and widgets that animate without freezing the entire page. Detect each API separately—support can differ.

⚡ Quick Reference

GoalCode / note
Read active VTdocument.activeViewTransition
Idle / nonenull
Start same-documentdocument.startViewTransition(() => { … })
Feature-detect"activeViewTransition" in Document.prototype
Await finishdocument.activeViewTransition?.finished
Skip animationdocument.activeViewTransition?.skipTransition()
MDN statusExperimental · Limited availability

🔍 At a Glance

Four facts about Document.activeViewTransition.

Kind
read-only

Instance

Returns
VT | null

ViewTransition

Status
experimental

Not Baseline

API
View Trans.

Document scope

Examples Gallery

Examples follow MDN Document: activeViewTransition. Labs feature-detect first. Real animations need a supporting browser and document.startViewTransition.

📚 Getting Started

Detect the property and read the idle null state.

Example 1 — Feature-Detect Safely

Check whether activeViewTransition exists on documents.

JavaScript
console.log({
  hasActiveViewTransition: "activeViewTransition" in Document.prototype,
  hasStartViewTransition: typeof document.startViewTransition === "function",
  tip: "Document.activeViewTransition is experimental — feature-detect first."
});
Try It Yourself

How It Works

Many browsers still report false. Treat missing support as normal and update the DOM without a view transition.

Example 2 — Idle Value Is null

Before any transition starts, the property should be null when present.

JavaScript
if (!("activeViewTransition" in document)) {
  console.log("activeViewTransition not supported");
} else {
  console.log({
    activeViewTransition: document.activeViewTransition,
    note: "null means no document-scoped transition is active"
  });
}
Try It Yourself

How It Works

After a transition finishes, the property returns to null again.

📈 Start, Await & Compare

MDN patterns when document.startViewTransition is available.

Example 3 — MDN Start, Check & Await finished

Start a transition, confirm it is active, then log when it finishes.

JavaScript
function updateUI() {
  heading.textContent = heading.textContent === "Hello" ? "Goodbye" : "Hello";
}

if (typeof document.startViewTransition !== "function") {
  updateUI();
  console.log("No View Transition API — instant update");
} else {
  document.startViewTransition(updateUI);

  if (document.activeViewTransition) {
    console.log("A view transition is currently active");
    document.activeViewTransition.finished.then(() => {
      console.log("View transition finished");
    });
  }
}
Try It Yourself

How It Works

Read activeViewTransition right after starting, or from any module while the transition is still in flight.

Example 4 — Same Object as the Return Value

Confirm activeViewTransition matches what startViewTransition returned.

JavaScript
if (typeof document.startViewTransition !== "function") {
  console.log("Cannot compare — startViewTransition missing");
} else {
  const vt = document.startViewTransition(() => {
    panel.dataset.state = panel.dataset.state === "a" ? "b" : "a";
  });
  console.log({
    sameReference: document.activeViewTransition === vt,
    tip: "Store vt or re-read activeViewTransition later"
  });
}
Try It Yourself

How It Works

Either approach works. Use the property when another part of your app needs the ongoing transition without threading the return value.

Example 5 — Document vs Element API Snapshot

See which active-transition hooks this browser exposes.

JavaScript
console.log({
  documentProp: "activeViewTransition" in Document.prototype,
  documentStart: typeof document.startViewTransition,
  documentActiveNow: document.activeViewTransition ?? null,
  elementProp: "activeViewTransition" in Element.prototype,
  elementStart: typeof Element.prototype.startViewTransition,
  status: "Document.activeViewTransition is experimental (document-scoped VT)"
});
Try It Yourself

How It Works

Document-scoped APIs may be available while element-scoped ones lag behind—detect each separately.

🚀 Common Use Cases

  • SPA route changes — await finished before focusing new content.
  • Skip or cancel an in-flight page transition from a global handler.
  • Guard UI actions while document.activeViewTransition != null.
  • Cross-document navigations — read alongside pagereveal.viewTransition.
  • Teaching document-scoped vs element-scoped View Transitions.
  • Debugging whether the page still has an active transition.

🔧 How It Works

1

Start a document transition

document.startViewTransition(callback) or a navigation VT begins.

Start
2

Browser captures & animates

Old/new snapshots cross-fade for the document scope.

Animate
3

activeViewTransition points at it

Same ViewTransition as the return value from startViewTransition.

Read
4

Settles back to null

When the transition ends or is skipped, the property clears.

📝 Notes

Limited / Experimental Support

Document.activeViewTransition is Experimental and not Baseline (CSS View Transitions Module Level 2). Always feature-detect and keep a plain DOM-update fallback. Logos use the shared browser-image-sprite.png sprite from this project.

Experimental · Not Baseline

Document.activeViewTransition

ViewTransition or null — the active document-scoped view transition.

Limited Experimental
Google Chrome Document VT — check current Chromium versions
Limited / Check
Microsoft Edge Follow Chromium View Transition support
Limited / Check
Opera Follow Chromium where available
Limited / Check
Mozilla Firefox May lag — feature-detect both start and active props
Limited
Apple Safari Check current Safari — feature-detect
Limited
Internet Explorer No View Transition API
No
Document.activeViewTransition Limited

Bottom line: Detect activeViewTransition and document.startViewTransition before use. Prefer storing the return value when convenient; use activeViewTransition when you need the ongoing transition later. Never require view transitions for core UX.

Conclusion

Document.activeViewTransition is an experimental read-only handle for the document-scoped ViewTransition currently running—or null when idle. Feature-detect it, pair it with document.startViewTransition(), and always keep a non-animated update path.

Continue with adoptedStyleSheets, ownerDocument, Element.activeViewTransition, activeElement, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Feature-detect activeViewTransition and startViewTransition
  • Fall back to plain DOM updates when unsupported
  • Treat null as idle (no active transition)
  • Use optional chaining for ?.finished and ?.skipTransition()
  • Respect prefers-reduced-motion when designing animations

❌ Don’t

  • Assign to activeViewTransition (it is read-only)
  • Assume every browser supports document-scoped transitions
  • Require view transitions for core product flows
  • Confuse it with element.activeViewTransition
  • Skip checking MDN compatibility for production apps

Key Takeaways

Knowledge Unlocked

Five things to remember about activeViewTransition

Experimental document-scoped ViewTransition accessor.

5
Core concepts
🎬02

ViewTransition

or null

Value
🔬03

Experimental

not Baseline

Status
🔗04

Pairs with

startViewTransition

API
🎯05

Fallback

plain DOM update

UX

❓ Frequently Asked Questions

A ViewTransition instance for the view transition currently active on the document, or null if none is active.
MDN marks Document.activeViewTransition as Experimental and Limited availability (CSS View Transitions Module Level 2). It is not Deprecated or Non-standard.
Yes. You read it to get the active ViewTransition (or null). You do not assign a transition to the property.
document.startViewTransition() starts a same-document transition and returns a ViewTransition. activeViewTransition lets you read that ongoing transition later without keeping your own reference.
When the document has no active view transition — before one starts, after it finishes, or if the API is unsupported.
Document.activeViewTransition is document-scoped (whole-page same-document transitions and cross-document cases via pagereveal/pageswap). Element.activeViewTransition is for element-scoped transitions on a single element subtree.
Did you know?

MDN lists three ways to reach the current ViewTransition: the return value of document.startViewTransition(), event.viewTransition on cross-document pagereveal / pageswap events, and document.activeViewTransition—the last one works uniformly without saving a reference first.

Next: adoptedStyleSheets

Adopt constructed CSSStyleSheet arrays on the document.

adoptedStyleSheets →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful