WarningThis API is not fully standardized across all browsers. Always check the isSupported flag before using its state in your logic.
NoteThis is particularly useful for verifying if a "transient activation" (a recent click/tap) exists before calling restricted APIs like requestFullscreen.
The useUserActivation hook provides access to the navigator.userActivation API, which allows developers to check for "sticky" activation (has the user ever interacted?) and "transient" activation (is there a current interaction window?). This is critical for triggering restricted browser features like playing audio, opening popups, or accessing the clipboard, which often require a fresh user gesture.
| Name | Type | Description |
|---|---|---|
| hasBeenActive | boolean | Indicates if the user has performed at least one interaction (sticky activation) since the page loaded. |
| isActive | boolean | Indicates if the user has interacted with the page recently enough to allow 'gated' APIs (transient activation). |
| isSupported | boolean | Indicates whether the UserActivation API is supported in the current browser. |
| refresh | () => void | Manually triggers a re-read of the navigator.userActivation state. |