Nine plugins available

Call native phone features from plain JavaScript

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.

  • Choose plugins per build
  • Results come from your phone
  • Five are Android only for now
Available plugins

Nine plugins you can use today

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.

  • Device

    Vibration

    Buzz the phone for a set time and strength, or play a custom pattern.

    Import
    lib/plugins/vibration.js
    Build setting
    vibration
  • Media

    Camera

    Open the camera to take a photo or record a video, with an optional time limit.

    Import
    lib/plugins/camera.js
    Build setting
    camera
    Android only
  • Media

    Microphone

    Record audio on the device and get back a file you can play in an audio element.

    Import
    lib/plugins/microphone.js
    Build setting
    microphone
    Android only
  • Media

    Image Picker

    Choose one or several images from the device gallery.

    Import
    lib/plugins/imagePicker.js
    Build setting
    image_picker
    Android only
  • Files

    File Picker

    Choose any file from the device, optionally limited to extensions such as pdf.

    Import
    lib/plugins/filePicker.js
    Build setting
    file_picker
    Android only
  • Files

    File Saver

    Save text, a Blob or a captured file through the system save dialog.

    Import
    lib/plugins/fileSaver.js
    Build setting
    file_saver
    Android only
  • Links and sharing

    Share

    Open the native share sheet with a text message or a link.

    Import
    lib/plugins/share.js
    Build setting
    share
  • Links and sharing

    In-App Browser

    Open a URL in the native browser instead of inside the app's WebView.

    Import
    lib/plugins/inAppBrowser.js
    Build setting
    in_app_browser
  • Ads

    AdMob

    Show banner, interstitial and rewarded ads through Google Mobile Ads.

    Import
    lib/plugins/ads.js
    Build setting
    google_mobile_ads

Cards marked Android only are limited to Android for now. iOS support is on the roadmap below.

Try it

Call a plugin and see what comes back

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.

My web app 9:41

Demo. The phone is simulated, and the sample values in responses are illustrative.

Your code
Response Ready
Activate a plugin

Turn a plugin on in your build, then import it

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.

  1. 1

    Build your developer app

    Zip your project and upload it on html2app.dev, as described on the developer app page.

  2. 2

    Add the plugins you need

    On the Plugins page, click Add New Plugin and select each plugin you want in the build.

  3. 3

    Configure the plugins

    Fill in any settings the dashboard asks for. AdMob also needs ad unit IDs, which your code sets with setAdUnitId.

  4. 4

    Install the bridge and import

    Run npm install @yandeu/js-bridge in your project. Import each plugin from its own file under lib/plugins/.

  5. 5

    Test on your phone

    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.

Build configuration Demo
    Imports for this build

    Plugins that are off are left out of the build, so their calls do not work.

    Call a plugin

    Four habits for every plugin call

    The calls follow one pattern. Check the result, treat a cancel as a normal outcome, and keep the files you need.

    1

    Import from the module file

    Each plugin has its own file under lib/plugins/. Import the plugins your app uses, and nothing else.

    2

    Check ok before you read the payload

    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.

    3

    Treat a cancel as a normal result

    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.

    4

    Keep the files you need

    Captured and picked files are removed when the local server starts or closes. Save anything you want to keep with FileSaver.saveUrl.

    app.js
    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.

    app.js
    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.

    On the roadmap

    More plugins are being built

    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.

    • Building now

      In-App Purchases

      Sell digital items inside your app.

    • Building now

      Game Services

      Platform sign-in and game features for your app.

    • Building now

      Local Notifications

      Show notifications from the app itself.

    • Building now

      Push Notifications

      Receive notifications sent from a server.

    • Building now

      Geolocation

      Read the device location, with the user's permission.

    • On the horizon

      iOS support

      Support for iPhone and iPad builds.

    Need a plugin that is not listed? Send us a request.

    Questions

    Common questions

    Do plugins work in a regular browser?

    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.

    How do I turn a plugin on?

    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.

    What does Android only mean?

    Camera, Image Picker, File Picker, File Saver and Microphone work on Android for now. iOS support is on the roadmap.

    Do I need to install anything in my project?

    Yes, the bridge package. Run npm install @yandeu/js-bridge, then import each plugin from its file under lib/plugins/.

    Where can I find every method and option?

    The JS Bridge API reference lists each plugin's methods. The plugins example repository shows the plugins in use.

    Build your developer app with the plugins you need

    Choose plugins on html2app.dev, then test each call on your phone with live reload and remote logs.