
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-hook-gyroscope
Advanced tools
A React hook to access data from the Gyroscope API.
Using npm:
npm install --save react-hook-gyroscope
Using yarn:
yarn add react-hook-gyroscope
import React from 'react'
import useGyroscope from 'react-hook-gyroscope'
const ComponentWithGyroscope = () => {
const gyroscope = useGyroscope()
return !gyroscope.error ? (
<ul>
<li>X: {gyroscope.x}</li>
<li>Y: {gyroscope.y}</li>
<li>Z: {gyroscope.z}</li>
</ul>
) : (
<p>No gyroscope, sorry.</p>
)
}
SensorOptionshttps://w3c.github.io/gyroscope/#gyroscope-interface
If you want to use this feature, simply provide useGyroscope with a SensorOptions object:
const gyroscope = useGyroscope({
frequency: 60, // cycles per second
})
You can supply a second parameter to useGyroscope which will be called every time the data from the Gyroscope API is updated. This callback function is then called with the gyroscope object with all its properties.
If you don't use SensorOptions, supply {} as your first argument.
const onGyroscopeUpdate = (gyroscope) => {
console.log('Here’s some new data from the Gyroscope API: ', gyroscope)
}
const gyroscope = useGyroscope({}, onGyroscopeUpdate)
Access to data from the Gyroscope API needs user permission.
If permission to access gyroscope was previously granted by the user, gyroscope data will be available. If permission to access was not granted previously, the user will be prompted to give permission when the component mounts.
Gyroscope API is available only in secure contexts (a.k.a. only using HTTPS).
Credit to Bence A. Tóth for his original hook code for Geolocation.
LGPL-3.0
FAQs
React hook for gyroscope access
The npm package react-hook-gyroscope receives a total of 25 weekly downloads. As such, react-hook-gyroscope popularity was classified as not popular.
We found that react-hook-gyroscope 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.