An open API service indexing awesome lists of open source software.

https://github.com/hikouki/hey-react-native

:email: Send message to react-native app from react-native-webview.
https://github.com/hikouki/hey-react-native

emit events message react-native react-native-webview typescript

Last synced: 4 months ago
JSON representation

:email: Send message to react-native app from react-native-webview.

Awesome Lists containing this project

README

        

# hey-react-native

![CI](https://github.com/hikouki/hey-react-native/workflows/CI/badge.svg)

Send message to react-native app from react-native-webview.

If not in the react-native-webview, It won't do anything.

## Install

```
npm install hey-react-native
```

## Usage

Please refer to [tests](https://github.com/hikouki/hey-react-native/blob/main/__tests__/index.spec.ts).

```typescript
import { HeyReactNative } from "hey-react-native";

const hey = new HeyReactNative({ debug: true });
hey.emit({ event: 'ping', value: 'pong' });

// => console.log {"event":"ping","value":"pong"}
```

If you want to specify a event name.

```typescript
import { HeyReactNative } from "hey-react-native";

const hey = new HeyReactNative<'ping'>({ debug: true });
hey.emit({ event: 'ping', value: 'pong' });
```

## License

hey-react-native is [MIT licensed](https://github.com/hikouki/hey-react-native/blob/main/LICENSE).