Import from the module file
Each plugin has its own file under lib/plugins/. Import the plugins your app uses, and nothing else.
Buzz the phone, open the share sheet, take a photo, record audio, pick files and show ads. You turn on each feature as a plugin in your build, import it, and call it like any other function.
Each card lists the import path, the setting that turns the plugin on in your build, and whether it is limited to Android. Select Try it to run a plugin in the lab below.
Buzz the phone for a set time and strength, or play a custom pattern.
Open the camera to take a photo or record a video, with an optional time limit.
Record audio on the device and get back a file you can play in an audio element.
Choose one or several images from the device gallery.
Choose any file from the device, optionally limited to extensions such as pdf.
Save text, a Blob or a captured file through the system save dialog.
Open the native share sheet with a text message or a link.
Open a URL in the native browser instead of inside the app's WebView.
Show banner, interstitial and rewarded ads through Google Mobile Ads.
No plugin matches. Try another word or category.
Cards marked Android only are limited to Android for now. iOS support is on the roadmap below.
Pick a plugin and press Call. Then finish the native step on the phone, such as taking a photo or cancelling. The panel shows the code you would write and the response your JavaScript gets back.
Demo. The phone is simulated, and the sample values in responses are illustrative.
A plugin only works in an app that includes it. Choose plugins in the dashboard, install the bridge in your project, and import the modules you use.
Zip your project and upload it on html2app.dev, as described on the developer app page.
On the Plugins page, click Add New Plugin and select each plugin you want in the build.
Fill in any settings the dashboard asks for. AdMob also needs ad unit IDs, which your code sets with setAdUnitId.
Run npm install @yandeu/js-bridge in your project. Import each plugin from its own file under lib/plugins/.
Start the server with --remoteLogs=true and connect the developer app. Console output from the phone appears in your terminal, which helps when a call fails.
Plugins that are off are left out of the build, so their calls do not work.
The calls follow one pattern. Check the result, treat a cancel as a normal outcome, and keep the files you need.
Each plugin has its own file under lib/plugins/. Import the plugins your app uses, and nothing else.
A call resolves to { ok: true, payload } or { ok: false, errorMessage }. Most calls return a promise, so use await. Vibration.vibrate is the exception and returns its result right away.
When the user cancels a camera or picker, the call still returns ok: true with file: null, or an empty array for several files. File Saver returns saved: false.
Captured and picked files are removed when the local server starts or closes. Save anything you want to keep with FileSaver.saveUrl.
import { Camera } from '@yandeu/js-bridge/lib/plugins/camera.js'
import { FileSaver } from '@yandeu/js-bridge/lib/plugins/fileSaver.js'
async function takeAndKeepPhoto() {
const res = await Camera.takePhoto()
if (!res.ok) return console.error(res.errorMessage)
if (!res.payload.file) return // the user cancelled
document.querySelector('img').src = res.payload.file.url
await FileSaver.saveUrl('photo.jpg', res.payload.file.url) // keep a copy
}
The same three steps apply to every plugin: import it, await the call, then check ok.
import { WebView } from '@yandeu/js-bridge'
if (!WebView.isReady) {
// Regular browser: hide the buttons that call plugins
}
Show plugin buttons only when the bridge is ready, so a regular browser never shows a button that cannot work.
These plugins are in progress and none of them is available yet. Names, scope and timing may change, so treat this list as a preview.
Sell digital items inside your app.
Platform sign-in and game features for your app.
Show notifications from the app itself.
Receive notifications sent from a server.
Read the device location, with the user's permission.
Support for iPhone and iPad builds.
Need a plugin that is not listed? Send us a request.
No. Plugins talk to the native shell, and a regular browser does not have one. A call returns ok: false with the message "Not running inside Flutter WebView". Test plugins in the developer app or in your built app.
Open the Plugins page in the dashboard, click Add New Plugin, select the plugins you need and configure them. Each build includes only the plugins you select, so change the list and build again when you add one.
Camera, Image Picker, File Picker, File Saver and Microphone work on Android for now. iOS support is on the roadmap.
Yes, the bridge package. Run npm install @yandeu/js-bridge, then import each plugin from its file under lib/plugins/.
The JS Bridge API reference lists each plugin's methods. The plugins example repository shows the plugins in use.
Choose plugins on html2app.dev, then test each call on your phone with live reload and remote logs.