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
| Area | Examples | Where |
|---|---|---|
| Core (always available) | Device and app info, permissions, biometrics, share sheet, plugin list | API reference |
| Plugins | Scanner, haptics, social login, in-app purchases, analytics, contacts, calendar | Native plugins |
| Events | Shake, shared content, purchase updates, background location | Events |
| Links without JavaScript | Simple calls from wapp:// links | URL 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
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_PARAMSwith the field name indetails.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
- Turn on the plugins you call in Integrations › Native plugins, and the device permissions in Permissions › Device.
- Build a new version: plugins and permissions are compiled into the app.
- 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.