# react-use-permissions

> React hook for Permissions API

Latest version **1.0.1** (published 2019-01-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-use-permissions
pnpm add react-use-permissions
yarn add react-use-permissions
bun add react-use-permissions
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-01-05 |
| First published | 2019-01-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 195.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sergio Xalambrí |
| Maintainers | sergiodxa |

## Links

- npm: https://www.npmjs.com/package/react-use-permissions
- npm.io page: https://npm.io/package/react-use-permissions

## Recent versions

- 1.0.1 (latest) — 2019-01-05
- 1.0.0 — 2019-01-05

## README

# `react-use-permsissions`

> React hook for Permissions API

> **Note:** This is using the new [React Hooks API Proposal](https://reactjs.org/docs/hooks-intro.html)
> which is subject to change until React 16.7 final.
>
> You'll need to install `react`, `react-dom`, etc at `^16.7.0-alpha.0`

## Install

```sh
yarn add react-use-permissions
```

## Usage

```js
import usePermissions from '../src';

const format = hasPermissions => {
  switch (hasPermissions) {
    // User has granted permissions
    case true: {
      return "Permissions granted";
    }
    // User has denied permissions
    case false: {
      return "Permissions denied";
    }
    // User will be prompted for permissions
    case null: {
      return "Asking for permissions";
    }
  }
}

function App() {
  const hasPermissions = usePermissions("geolocation");
  const content = format(hasPermissions);
  return <h1>{content}</h1>;
}
```

---
_Source: https://npm.io/package/react-use-permissions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
