react-use-navigator-permissions
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

useNavigatorPermissions Hook 🔗 🗺️

Build Status Codecov Coverage

This React Hook allows you to make a query to see if a user has either accepted or denied permissions to a given navigator api.

Getting Started ✈️

You can install this hook using Yarn.

yarn add react-use-navigator-permissions

It can then be included in your project like so.

import useNavigatorPermissions from 'react-use-navigator-permissions'
 
const Component = () => {
  const { status, error } = useNavigatorPermissions('geolocation')
 
  return (
    <div>{status}</div>
  )
}

The first argument accepts the api name, and the second accepts a series of configuration parameters.

Browser Compatibility 📣

This hook utilizes window.navigator.permissions which is not widely supported by all browsers. For information on what browser supports what please refer to the documentation.

Package Sidebar

Install

npm i react-use-navigator-permissions

Weekly Downloads

8

Version

0.1.2

License

MIT

Unpacked Size

13.8 kB

Total Files

12

Last publish

Collaborators

  • jamesives