JavaScript Navigator userActivation Property

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline

What You’ll Learn

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

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.

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.

📝 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
}

⚡ Quick Reference

GoalCode
Get UserActivationnavigator.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)

🔍 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

📋 Transient vs Sticky Activation

isActive (transient)hasBeenActive (sticky)
MeaningUser is interacting now (or very recently)User has interacted at least once since load
Resets?Becomes false after the activation window endsStays true for the rest of the page lifetime
Typical useStart media / privileged APIs right after a clickAllow animations or softer features after first gesture
MDN example ideaRequest playing mediaAuto-play an animation

Examples Gallery

Examples follow MDN navigator.userActivation patterns. Prefer Try It Yourself — click the page to see sticky activation flip to true.

📚 Getting Started

Detect the API and read both flags once.

Example 1 — Feature Detection

Check whether userActivation exists on navigator.

JavaScript
const supported = "userActivation" in navigator;
console.log(supported ? "userActivation available" : "userActivation missing");
Try It Yourself

How It Works

Modern browsers expose this Baseline API. Still feature-detect for older engines.

Example 2 — Read Both Flags

Log transient and sticky state on page load.

JavaScript
if (!("userActivation" in navigator)) {
  console.log("userActivation not supported");
} else {
  console.log("isActive: " + navigator.userActivation.isActive);
  console.log("hasBeenActive: " + navigator.userActivation.hasBeenActive);
}
Try It Yourself

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.
Try It Yourself

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());
Try It Yourself

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());
Try It Yourself

How It Works

Matches MDN’s sticky-activation example idea: allow an animation after the user has engaged.

🚀 Common Use Cases

  • Media autoplay UX — show Play until transient activation is available.
  • Device APIs — call pickers (usb, serial, hid) from a click when isActive.
  • Fullscreen / clipboard — many features need a user gesture window.
  • Soft engagement gates — start decorative animations after hasBeenActive.
  • Debugging gated failures — log activation flags when an API rejects without a gesture.

🧠 How User Activation Works

1

Page loads idle

Usually neither sticky nor transient activation yet.

Load
2

User clicks or taps

Transient activation becomes true for a short window.

Gesture
3

Sticky stays true

hasBeenActive remains true after that first interaction.

Sticky
4

Privileged APIs can run

Call gated features during the activation window when required.

📝 Notes

  • Baseline Widely available (MDN, since November 2023).
  • Not Deprecated, Experimental, or Non-standard — no status banner required.
  • Window context only — not available in workers.
  • Read-only UserActivation with isActive and hasBeenActive.
  • Related: userAgent, usb, serial, hid.

Universal Browser Support

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.

Universal Widely available
Google Chrome UserActivation · Desktop & Mobile
Full support
Mozilla Firefox UserActivation · Desktop & Mobile
Full support
Apple Safari UserActivation · macOS & iOS
Full support
Microsoft Edge UserActivation · Chromium
Full support
Opera UserActivation · Modern versions
Full support
Internet Explorer No UserActivation support
Unavailable
userActivation Excellent

Bottom line: Feature-detect navigator.userActivation, prefer calling privileged APIs from click handlers, and use sticky activation for softer engagement gates.

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.

Continue with userAgent, usb, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Feature-detect "userActivation" in navigator
  • Call privileged APIs from click / tap handlers
  • Use isActive for short-lived privileges
  • Use hasBeenActive for “engaged once” UX
  • Explain why a Play / Allow button is needed

❌ Don’t

  • Expect activation inside Web Workers
  • Assume isActive stays true forever
  • Skip a user gesture for device pickers / autoplay
  • Treat the flags as writable
  • Assign to navigator.userActivation

Key Takeaways

Knowledge Unlocked

Five things to remember about userActivation

Baseline gesture state — transient now, sticky since load, window only.

5
Core concepts
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.

Learn userAgent Next

Baseline User-Agent string — great for logs, weak for sniffing.

userAgent →

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.

8 people found this page helpful