Docs
Native bridge
Inside your app, every page of your website gets a window.W2A object. Use it to reach native features from ordinary JavaScript. In a normal browser window.W2A is undefined, so guard calls with optional chaining.
window.addEventListener("w2a:ready", () => {
console.log("Running in the app", W2A.platform);
});Events
w2a:ready: the runtime finished mounting your configured features.w2a:scan: a barcode was scanned;event.detailis{ value, format }.
API
W2A.isNative / W2A.platformtrue inside the app; "android" | "ios" | "web".
if (window.W2A?.isNative) showAppOnlyUI();
W2A.share({ title, text, url })Opens the OS share sheet. Needs “Native sharing”. navigator.share() is also upgraded automatically.
W2A.share({ title: document.title, url: location.href });W2A.haptic("LIGHT" | "MEDIUM" | "HEAVY")Subtle vibration feedback.
button.onclick = () => W2A.haptic("MEDIUM");W2A.scan({ formats?, openUrls? })Native barcode / QR scanner. Resolves { value, format } and fires a w2a:scan event. Needs “Barcode & QR scanner”.
const r = await W2A.scan({ formats: "QR_CODE" });
if (r) checkIn(r.value);W2A.setBadge(index, text)Sets the badge on a bottom-navigation tab. Pass "" to clear.
W2A.setBadge(1, cart.count);
W2A.openSheet({ title, body, items })Opens the native bottom sheet. With no argument, opens the configured one.
W2A.openSheet({ title: "Share", items: [{ label: "Copy link", icon: "share", url: "" }] });W2A.openMenu() / W2A.closeMenu()Control the side menu.
W2A.openMenu();
W2A.go(url) / W2A.openExternal(url)Navigate using the app’s link rules (internal, in-app browser or system browser).
W2A.go("tel:+10000000000");W2A.openUpi({ pa, pn, am, tn })Launches a UPI app (GPay, PhonePe, Paytm…) for a payment.
W2A.openUpi({ pa: "shop@upi", pn: "My Shop", am: "499.00", tn: "Order 42" });W2A.contacts.list()Reads the address book after permission. Needs “Native contacts” (Business).
const people = await W2A.contacts.list();
W2A.bleThe full Bluetooth LE plugin object. Needs “Bluetooth LE” (Business).
await W2A.ble.initialize(); const d = await W2A.ble.requestDevice();
W2A.track(name, params)Logs a Firebase Analytics event. Needs “Firebase Analytics”.
W2A.track("purchase", { value: 49.9, currency: "INR" });W2A.lock()Shows the biometric / passcode lock now.
W2A.lock();
W2A.toast(text)Short native-looking message.
W2A.toast("Saved");W2A.refresh()Fetches the latest over-the-air config immediately.
await W2A.refresh();
Notes
- Features must be enabled for the app (Features tab) and built into the binary for native-backed calls.
- Navigation, banners, modals and loaders update over the air; native plugins and permissions need a new build.
- Custom CSS / JavaScript from “Website overrides” only runs on your own domains.