Skip to main content
JavaScript Bridge2 min read

JavaScript Bridge Overview

What the WebAppStudio JavaScript Bridge is, what your website can do with window.wapp, how calls and results work, and where to find the full reference.

Overview

The JavaScript Bridge lets your website, running inside your WebAppStudio app, call native phone features: ask for a permission, confirm with Face ID, open the share sheet, scan a barcode, sign in with Apple, sell a subscription and more.

On allowed pages, the app adds a global window.wapp object before your page's scripts run. Each call is sent to the native app and returns a promise with the result. In a normal browser window.wapp does not exist, so the same website keeps working on the web.

There is nothing to install on your website.

What you can do

AreaExamplesWhere
Core (always available)Device and app info, permissions, biometrics, share sheet, plugin listAPI reference
PluginsScanner, haptics, social login, in-app purchases, analytics, contacts, calendarNative plugins
EventsShake, shared content, purchase updates, background locationEvents
Links without JavaScriptSimple calls from wapp:// linksURL protocol

Many features need no bridge at all: links and location.href navigate as usual, <input type="file"> opens the camera, navigator.geolocation and navigator.share work once the matching permissions are on.

A first call

javascript
if (window.wapp) {
  const result = await wapp.haptics.trigger({ style: 'impactLight' });
  if (!result.success) console.log(result.code, result.error);
}

How calls work

  • Parameters are a plain JSON object, validated by the app. Wrong or extra fields return INVALID_PARAMS with the field name in details.field.
  • Promises never reject. They resolve { success: true, ...result } or { success: false, code, error, details? }. See error codes.
  • Events from the app (for example a shake) arrive through wapp.on(name, handler).

What must be set up in the app

  1. Turn on the plugins you call in Integrations › Native plugins, and the device permissions in Permissions › Device.
  2. Build a new version: plugins and permissions are compiled into the app.
  3. Check Website access: by default every page of your website may use the bridge, and no other site can. See Website access.

Platforms

The bridge works on Android and iOS with the same code. A few methods exist on one platform only (for example Sign in with Apple on iOS) and answer UNSUPPORTED_PLATFORM elsewhere.

Older names

window.WebAppStudio, wsta and ctn are aliases of wapp, so existing code keeps working. Use wapp for new code.

Next steps