# react-hook-linear-acceleration

> React hook for Linear Acceleration sensor access

Latest version **1.1.3** (published 2022-05-01) · LGPL license · 0 weekly downloads

## Install

```sh
npm install react-hook-linear-acceleration
pnpm add react-hook-linear-acceleration
yarn add react-hook-linear-acceleration
bun add react-hook-linear-acceleration
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2022-05-01 |
| First published | 2022-04-19 |
| Weekly downloads | 0 |
| License | LGPL |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Masao Kitamura |
| Maintainers | masao |
| Keywords | react, hook, linear, acceleration |

## Links

- npm: https://www.npmjs.com/package/react-hook-linear-acceleration
- Repository: https://github.com/masaok/react-hook-linear-acceleration
- Homepage: https://github.com/masaok/react-hook-linear-acceleration#readme
- Issues: https://github.com/masaok/react-hook-linear-acceleration/issues
- npm.io page: https://npm.io/package/react-hook-linear-acceleration

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2022-05-01
- 1.1.2 — 2022-04-28
- 1.1.1 — 2022-04-19

## README

A React hook to access data from the [Linear Acceleration API](https://developer.mozilla.org/en-US/docs/Web/API/LinearAccelerationSensor).

## Installation

Using `npm`:

```sh
npm install --save react-hook-linear-acceleration
```

Using `yarn`:

```sh
yarn add react-hook-linear-acceleration
```

## Usage

```jsx
import React from "react";
import useLinearAcceleration from "react-hook-linear-acceleration";

const MyComponent = () => {
  const sensor = useLinearAcceleration();

  return !sensor.error ? (
    <ul>
      <li>X: {sensor.x}</li>
      <li>Y: {sensor.y}</li>
      <li>Z: {sensor.z}</li>
    </ul>
  ) : (
    <p>No linear acceleration, sorry.</p>
  );
};
```

## Notes

Access to data from the Linear Acceleration API needs user permission.

If permission to access Linear Acceleration was previously granted by the user, Linear Acceleration data will be available. If permission to access was not granted previously, the user will be prompted to give permission when the component mounts.

## Caveats

Linear Acceleration API is available only in secure contexts (only using HTTPS).

## Credits

Credit to [Bence A. Tóth](https://github.com/bence-toth) for his original hook code for [Geolocation](https://www.npmjs.com/package/react-hook-geolocation).

## License

LGPL-3.0

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