Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
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.
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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.