Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
react-user-agent-client-hints
Advanced tools
React hook implementing the User-Agent Client Hints API to get information about the browser and operating system of a user.
React hook implementing the User-Agent Client Hints API to get information about the browser and operating system of a user.
The useUserAgentData hook allows you to fetch high entropy user-agent data from the browser. It returns an object with the user-agent data, or an error if something went wrong.
To use the useUserAgentData hook, you must pass an array of hints as an argument. These hints are used to request specific user-agent data.
import { useUserAgentData } from "path/to/hook"
function MyComponent() {
const [userAgentData, error] = useUserAgentData(["brand", "version"])
if (error) {
return <div>{error.message}</div>
}
if (!userAgentData) {
return <div>Loading...</div>
}
return (
<div>
<p>Brands: {userAgentData.brands.map(brand => brand.brand).join(", ")}</p>
<p>Mobile: {userAgentData.mobile ? "Yes" : "No"}</p>
<p>Architecture: {userAgentData.architecture}</p>
<p>Bitness: {userAgentData.bitness}</p>
<p>Model: {userAgentData.model}</p>
<p>Platform: {userAgentData.platform}</p>
<p>Platform Version: {userAgentData.platformVersion}</p>
<p>UA Full Version: {userAgentData.uaFullVersion}</p>
<p>Wow64: {userAgentData.wow64 ? "Yes" : "No"}</p>
<p>
Full Version List:{" "}
{userAgentData.fullVersionList.map(brand => brand.brand).join(", ")}
</p>
</div>
)
}
interface UADataValues {
brands: NavigatorUABrandVersion[]
mobile: boolean
architecture: string
bitness: string
model: string
platform: string
platformVersion: string
uaFullVersion: string
wow64: boolean
fullVersionList: NavigatorUABrandVersion[]
}
If there is an error while fetching the user-agent data, useUserAgentData will return an error object with a message. The possible error messages are:
FAQs
React hook implementing the User-Agent Client Hints API to get information about the browser and operating system of a user.
The npm package react-user-agent-client-hints receives a total of 17 weekly downloads. As such, react-user-agent-client-hints popularity was classified as not popular.
We found that react-user-agent-client-hints 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
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.