# react-native-webview-bridge-seamless

> make it easy to invoke functions on webview and in react

Latest version **0.0.15** (published 2020-05-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-native-webview-bridge-seamless
pnpm add react-native-webview-bridge-seamless
yarn add react-native-webview-bridge-seamless
bun add react-native-webview-bridge-seamless
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.15 |
| Published | 2020-05-05 |
| First published | 2019-03-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 31.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Kirill Kulakov |
| Maintainers | kirill578 |
| Keywords | webview, bridge |

## Links

- npm: https://www.npmjs.com/package/react-native-webview-bridge-seamless
- Repository: https://github.com/kirill578/react-native-webview-bridge-seamless
- Issues: https://github.com/kirill578/react-native-webview-bridge-seamless/issues
- npm.io page: https://npm.io/package/react-native-webview-bridge-seamless

## Dependencies (1)

- [uuid](https://npm.io/package/uuid.md) ^3.3.2

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.0.15 (latest) — 2020-05-05
- 0.0.14 — 2020-04-29
- 0.0.13 — 2020-04-29
- 0.0.12 — 2020-03-20
- 0.0.11 — 2019-07-29
- 0.0.10 — 2019-06-06
- 0.0.9 — 2019-04-07
- 0.0.8 — 2019-03-27
- 0.0.7 — 2019-03-19
- 0.0.6 — 2019-03-19
- 0.0.5 — 2019-03-19
- 0.0.3 — 2019-03-19
- 0.0.2 — 2019-03-19
- 0.0.1 — 2019-03-19

## README

# Setup

install react native webview package, the library wont work with the default webview

```
yarn install react-native-webview
```

install package

```
yarn install react-native-webview-bridge-seamless
```

make sure you import webview from `react-native-webview` and not from `react-native`

```
import {WebView, WebViewSharedProps} from 'react-native-webview';
import {withWebViewBridge} from 'react-native-webview-bridge-seamless';
```

wrap the webview

```
export const WebViewWithBridge = withWebViewBridge(WebView);
```

# Usage

```js
class MySmartWebView extends React.Component<> {
    constructor(props) {
        super(props);
        this.getToken = this.getToken.bind(this);
    }

    async getToken(type) {
       if (type === 'A')
          return await getTokenA();
       else
          return await getTokenB();
    }

    render() {
       return <WebViewWithBridge
            source={{uri: 'https://your-page.io'}}
            reactNativeApi={{
                getToken: this.getToken
            }}
         />
    }
}

```

inside your web application we can interact with the defined app in the following way

```js
const timeout = 5000; // promise will fail if no response in 5 seconds
const tokenA = await window.getReactNativeApi(timeout).getToken('A');
```

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