View on GitHub

WebApiBridge

API support for iframes and React Native WebViews

WebApiBridge

WebApiBridge provides a function call API interface between Javascript processes that pass MessageEvent objects such as a a web page and an iframe or a React Native application and a web app running in a react-native-webview.

Features

Installation

If you’re using npm:

npm install --save @precor/web-api-bridge

or, if you’re using yarn:

yarn add @precor/web-api-bridge

Type Checking

a Typescript definition file is included. The Proptype declaration for Message is included in types/shapes.js, i.e. to use it:

import { Message } from '@precor/web-api-bridge/types/shapes';

Documentation

WebApiBridge Class

Examples

react-iframe is a simple react implementation of an API between a parent and an iframe.

react-multi is a react implementation of an API between a parent and multiple iframes.

webapp-library extends the react-multi example by creating a functional library abstraction over the bridge for the web app iframes. It also demonstrates mulitiple apis per window and dynamic additions of apis after the iframe based web apps are loaded.

react-native is a simple react implementation of an API between a react-native application and a web application loaded as a webview.

Gotchas