files/en-us/web/api/useractivation/index.md
{{APIRef("HTML DOM")}}
The UserActivation interface provides information about whether a user is currently interacting with the page, or has completed an interaction since page load.
This API is only available in the window context and not exposed to workers.
An object of this type is accessed via the {{domxref("navigator.userActivation")}} property, and can be used to query information about a window's user activation state.
A user activation either implies that the user is currently interacting with the page, or has completed an interaction since page load. User activation can be triggered by a button click, pointer touch, or some other user interaction with the page.
There are two kinds of window user activation states:
See Features gated by user activation for more information and a list of APIs that require either sticky or transient user activation.
Use {{domxref("navigator.userActivation")}} to access the UserActivation object, and then {{domxref("UserActivation.isActive")}} to check whether the user is currently interacting with the page ({{Glossary("Transient activation")}}).
if (navigator.userActivation.isActive) {
// proceed to request playing media, for example
}
Use {{domxref("UserActivation.hasBeenActive")}} to check whether the user has ever interacted with the page ({{Glossary("Sticky activation")}}).
if (navigator.userActivation.hasBeenActive) {
// proceed with auto-playing an animation, for example
}
{{Specifications}}
{{Compat}}