navigator.userActivation returns a UserActivation object for the current window. Learn isActive (transient) vs hasBeenActive (sticky), why browsers gate APIs behind gestures, five examples, and try-it labs.
01
Kind
Read-only property
02
Returns
UserActivation
03
Baseline
Widely available
04
Now?
isActive
05
Ever?
hasBeenActive
06
Scope
Window only
Fundamentals
Introduction
Many browser features must wait for a user gesture — a click, tap, or key press — so pages cannot autoplay loud media, open device pickers, or go fullscreen without intent.
navigator.userActivation gives you a UserActivation object that answers two beginner-friendly questions:
Is the user interacting right now? — isActive (transient activation)
Has the user interacted at least once since load? — hasBeenActive (sticky activation)
💡
Window only
MDN: this API is available in the window context and is not exposed to Web Workers.
Concept
Understanding the userActivation Property
Think of navigator.userActivation as a status light for user gestures on this tab — not a method you call to “activate” the user.
UserActivation — object returned by the property.
isActive — transient: user is currently interacting (or recently did).
hasBeenActive — sticky: at least one interaction since page load.
Triggers — button clicks, pointer touches, and similar interactions.
Gated APIs — many features require sticky or transient activation.
Foundation
📝 Syntax
General form of the property:
JavaScript
navigator.userActivation
Value
A UserActivation object for the current window.
Common patterns
JavaScript
// Feature-detect:
if ("userActivation" in navigator) {
// Supported
}
// Transient activation (MDN):
if (navigator.userActivation.isActive) {
// proceed to request playing media, for example
}
// Sticky activation (MDN):
if (navigator.userActivation.hasBeenActive) {
// proceed with auto-playing an animation, for example
}
Cheat Sheet
⚡ Quick Reference
Goal
Code
Get UserActivation
navigator.userActivation
Feature detect
"userActivation" in navigator
Transient (now)
navigator.userActivation.isActive
Sticky (ever since load)
navigator.userActivation.hasBeenActive
Workers?
Not available — window only
Writable?
No (read-only property / flags)
Snapshot
🔍 At a Glance
Four facts to remember about navigator.userActivation.
Returns
UserActivation
Gesture state
Status
Baseline
Widely available
Transient
isActive
Current gesture
Sticky
hasBeenActive
Since page load
Compare
📋 Transient vs Sticky Activation
isActive (transient)
hasBeenActive (sticky)
Meaning
User is interacting now (or very recently)
User has interacted at least once since load
Resets?
Becomes false after the activation window ends
Stays true for the rest of the page lifetime
Typical use
Start media / privileged APIs right after a click
Allow animations or softer features after first gesture
MDN example idea
Request playing media
Auto-play an animation
Hands-On
Examples Gallery
Examples follow MDN navigator.userActivation patterns. Prefer Try It Yourself — click the page to see sticky activation flip to true.
isActive: false
hasBeenActive: false
(often both false on a fresh load before any click)
How It Works
Before the first gesture, sticky activation is usually false. Transient is true only around an interaction.
📈 Practical Patterns
Update on click, gate an action, and compare both flags live.
Example 3 — Update After a Click
Show how hasBeenActive becomes sticky after a user gesture.
JavaScript
function report() {
if (!("userActivation" in navigator)) {
return "userActivation not supported";
}
return (
"isActive: " + navigator.userActivation.isActive +
"\nhasBeenActive: " + navigator.userActivation.hasBeenActive
);
}
console.log("before click:\n" + report());
// After a button click, call report() again — hasBeenActive should be true.
before click:
isActive: false
hasBeenActive: false
(after click in the lab: hasBeenActive becomes true)
How It Works
Sticky activation stays true for the rest of the page lifetime once the user has interacted.
Example 4 — Gate an Action on isActive
MDN-style check before a privileged step (for example starting media).
JavaScript
function tryStartMedia() {
if (!("userActivation" in navigator)) {
return "API missing — use a click handler as a fallback.";
}
if (navigator.userActivation.isActive) {
return "Transient activation OK — proceed to request playing media.";
}
return "Not active yet — ask the user to click a Play button first.";
}
console.log(tryStartMedia());
Not active yet — ask the user to click a Play button first.
(or the OK message when called inside a click handler)
How It Works
Call privileged APIs from the same user-gesture turn when possible — that is when isActive is most useful.
Example 5 — Sticky Gate for Softer Features
Use hasBeenActive for features that only need “user has engaged once.”
JavaScript
function maybeAnimate() {
if (!("userActivation" in navigator)) {
return "API missing.";
}
if (navigator.userActivation.hasBeenActive) {
return "Sticky activation OK — proceed with an animation.";
}
return "Waiting for the first user gesture on this page.";
}
console.log(maybeAnimate());
navigator.userActivation is Baseline Widely available across modern browsers (MDN: since November 2023). Use it to query transient and sticky user activation in the window context.
✓ Baseline · Widely available
Navigator.userActivation
UserActivation entry point — check isActive (transient) and hasBeenActive (sticky) before gated APIs.
UniversalWidely available
Google ChromeUserActivation · Desktop & Mobile
Full support
Mozilla FirefoxUserActivation · Desktop & Mobile
Full support
Apple SafariUserActivation · macOS & iOS
Full support
Microsoft EdgeUserActivation · Chromium
Full support
OperaUserActivation · Modern versions
Full support
Internet ExplorerNo UserActivation support
Unavailable
userActivationExcellent
Bottom line: Feature-detect navigator.userActivation, prefer calling privileged APIs from click handlers, and use sticky activation for softer engagement gates.
Wrap Up
Conclusion
navigator.userActivation is the Baseline way to read window user-activation state. Use isActive for transient “right now” checks and hasBeenActive for sticky “user engaged once” checks before gated features.
Baseline gesture state — transient now, sticky since load, window only.
5
Core concepts
📄01
Returns
UserActivation
Value
⚡02
Now
isActive
Transient
🔁03
Ever
hasBeenActive
Sticky
🖥04
Scope
window only
Context
🎯05
Use
gate APIs
Gestures
❓ Frequently Asked Questions
It is a read-only Navigator property that returns a UserActivation object with information about the current window’s user activation state — whether the user is interacting now, or has interacted since page load.
No. MDN marks it Baseline Widely available (since November 2023). It is not Deprecated, Experimental, or Non-standard.
UserActivation.isActive is true during transient activation — roughly while the user is currently interacting with the page (for example shortly after a click).
UserActivation.hasBeenActive is true for sticky activation — the user has completed at least one interaction since the page loaded.
Many powerful APIs (autoplay, clipboard write, device pickers, fullscreen, etc.) are gated behind a user gesture so sites cannot surprise users without interaction.
No. MDN notes UserActivation is only available in the window context and is not exposed to workers.
Did you know?
Browsers publish lists of features gated by user activation. navigator.userActivation lets your code ask the same question the browser already uses for security and UX.