
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
@react-hook/mouse-position
Advanced tools
A React hook for tracking the position of the mouse as it moves around an element.
A React hook for tracking the position of the mouse as it moves around an element.
yarn add @react-hook/mouse-position
import useMousePosition from '@react-hook/mouse-position'
const F = props => {
const [mousePositionRef, mousePosition] = useMousePosition(
0, // enterDelay
0, // leaveDelay
30, // fps
)
return (
<div ref={mousePositionRef}>
Hover me and see where I am relative to the element:<br/>
x: ${mousePosition.x}
y: ${mousePosition.y}
</div>
)
}
useMousePosition(enterDelay: number, leaveDelay: number, fps: number)enterDelay
<number>0mousemove eventsleaveDelay
<number>0mousemove eventsfps
<number>30<Array>
domRef
<React.useRef>ref propertypositionState
<object>x
<int>null if mouse is not over the elementy
<int>null if mouse is not over the elementpageX
<int>null
if mouse is not over the elementpageY {integer}
<int>null if
mouse is not over the elementclientX
<int>null if mouse
is not over the elementclientY
<int>null if mouse
is not over the elementscreenX
<int>null if mouse
is not over the elementscreenY
<int>null if
mouse is not over the elementelementWidth
<int>DOMRect.width of the element, null if mouse is not over
the elementelementHeight
<int>DOMRect.height of the element, null if mouse is not over
the elementisOver {bool}
<bool>true if the mouse is currently hovering over the elementFAQs
A React hook for tracking the position, hover, and down state of the mouse as it interacts with an element with interop between touch and mouse devices.
We found that @react-hook/mouse-position demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.