# react-native-usb

> A React Native module for USB communication

Latest version **0.1.1** (published 2019-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-usb
pnpm add react-native-usb
yarn add react-native-usb
bun add react-native-usb
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2019-01-03 |
| First published | 2019-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 770.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Andy Shea |
| Maintainers | andy-shea |
| Keywords | react-native, usb |

## Links

- npm: https://www.npmjs.com/package/react-native-usb
- npm.io page: https://npm.io/package/react-native-usb

## Dependencies (2)

- [buffer](https://npm.io/package/buffer.md) ^5.2.1
- [events](https://npm.io/package/events.md) ^3.0.0

## Recent versions

- 0.1.1 (latest) — 2019-01-03
- 0.1.0 — 2019-01-02

## README

# react-native-usb

## Getting started

`npm install react-native-usb --save`

or

`yarn add react-native-usb`


### Mostly automatic installation

`react-native link react-native-usb`

### Manual installation

#### Android

1. Open up `android/app/src/main/java/[...]/MainApplication.java`
  - Add `import me.andyshea.ReactNativeUsbPackage;` to the imports at the top of the file
  - Add `new ReactNativeUsbPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
  	```
  	include ':react-native-usb'
  	project(':react-native-usb').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-usb/android')
  	```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
  	```
      compile project(':react-native-usb')
  	```

## Usage
```javascript
import usb from 'react-native-usb';

// connect to device
await usb.connect(vendorId, productId);

// setup data event listener
usb.on('data', data => {
  console.log(data);
});

// send data to device
usb.write([0x01, 0x02, 0x03]);

// disconnect when finished
usb.disconnect();
```

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