Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-user-agent-client-hints

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-user-agent-client-hints

[![codecov](https://codecov.io/gh/zaknicholsdev/react-user-agent-client-hints/branch/develop/graph/badge.svg)](https://codecov.io/gh/zaknicholsdev/react-user-agent-client-hints)

  • 0.1.5
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React User Agent Client Hints

codecov

example workflow

React hook implementing the User-Agent Client Hints API to get information about the browser and operating system of a user.

Potential Use Cases

  • Providing custom-tailored polyfills to users on identifying that their browser lacked some web platform feature.
  • Working around browser bugs.
  • Recording browser analytics.
  • Adapting content based on user-agent information. This includes serving different content to mobile devices, in particular devices identified as low-powered. It might also include adapting the design to tailor the interfaces to the user's OS, or providing links to OS-specific ones.
  • Providing a notification when a user logs in from a different browser or device, as a security feature.
  • Providing the correct binary executable, on a site offering a download.
  • Collecting information about the browser and device to identify application errors.
  • Blocking spammers, bots, and crawlers.

Installation

$ npm install react-user-agent-client-hints

Examples

import { useUserAgentClientHints, Hint } from "react-user-agent-client-hints"

/*
 * An array containing the hints to be returned. Declare in a useMemo or in module scope for referential stability.
 */
const hints: Hint[] = useMemo(
  () => [
    "architecture",
    "model",
    "bitness",
    "platformVersion",
    "fullVersionList"
  ],
  []
)

/*
 * High entropy potentially reveals more info about the operating
 * system and browser. Under the hood is async allowing time for the
 * browser to request user permission, or make other checks.
 */
const highEntropyUAData = useUserAgentClientHints({ entropy: "high", hints })

/*
 * Low entropy runs sync, but potentially does not reveal enough information
 * able to identify a user.
 */
const lowEntropyUAData = useUserAgentClientHints({ entropy: "low" })

/*
 * Can call without parameters too.
 */
const UADataNoParams = useUserAgentClientHint()

References

FAQs

Package last updated on 30 May 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc