Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/webviewjs/webview/llms.txt

Use this file to discover all available pages before exploring further.

WebviewJS on Android is an experimental platform target that embeds a native WebView inside an Android Activity using Tao’s Android backend. It supports both 64-bit ARM (aarch64) and 32-bit ARM (armv7) devices, making it compatible with the vast majority of Android hardware. The API surface is intentionally minimal — most windowing primitives do not apply to Android, and the two Android-specific methods (androidContentRect() and androidConfig()) give you the information you need to integrate the webview with the rest of your native UI.
Android support is experimental. Pre-built binaries may not be available for all minor versions. APIs and behaviour may change without a semver-breaking release. Test on physical devices before shipping.

Supported Architectures

WebviewJS targets the two most common Android CPU architectures:
ArchitectureAndroid target triple
ARM64 (64-bit)aarch64-linux-android
ARMv7 (32-bit)armv7-linux-androideabi
x86 and x86_64 Android targets (used in the emulator) are not currently supported. Use a physical ARM device or an ARM-capable emulator (e.g. Apple Silicon Mac’s Android emulator with ARM images).

Android-Specific Runtime APIs

androidContentRect()

androidContentRect() returns the current native content inset rectangle — the area within the Activity window that the WebView occupies, in pixels relative to the Activity’s top-left corner. This is useful for laying out additional native views (e.g. a bottom navigation bar) alongside the webview:
const rect = win.androidContentRect();

console.log(rect);
// { left: 0, top: 0, right: 1080, bottom: 1920 }

const width  = rect.right  - rect.left;
const height = rect.bottom - rect.top;
console.log(`Content area: ${width}×${height} px`);
The returned object conforms to AndroidContentRect:
interface AndroidContentRect {
  left:   number;  // left edge in pixels
  top:    number;  // top edge in pixels
  right:  number;  // right edge in pixels
  bottom: number;  // bottom edge in pixels
}

androidConfig()

androidConfig() returns the current Android configuration as a diagnostic string. This is intended for debugging and logging — for example, to record device locale, screen density, and orientation at crash time:
const config = win.androidConfig();
console.log('Android config:', config);
// e.g. "mcc=0 mnc=0 locale=en_US touchscreen=3 ..."
androidConfig() is a diagnostic utility and should not be used to make layout decisions. Use androidContentRect() for layout, and standard web APIs (screen.width, window.devicePixelRatio, etc.) for responsive design.

Unsupported APIs on Android

Some WebviewJS features are not available on Android and will throw an error or silently no-op:
app.createTrayIcon() returns an error on Android — the Android platform has no system tray concept. Guard tray creation with a platform check if your code targets multiple platforms.
win.openFileDialog() is not implemented on Android. Use the Web File API (<input type="file">) or a custom protocol handler to access the filesystem.

Configuration Tips

1

Use logical pixels for layout

Android devices vary widely in pixel density. Always pass logical: true to setSize() and setPosition(), or set logical: true in BrowserWindowOptions, so your layout uses density-independent pixels.
const win = app.createBrowserWindow({ logical: true, width: 360, height: 640 });
2

Load content via a custom protocol

Android’s WebView has restrictions on file: access to app-internal assets. Register a custom protocol via win._registerProtocol() to serve your HTML, CSS, and JS, then load from it:
webview.loadUrl('app://localhost/index.html');
3

React to content rect changes

The system keyboard, navigation bars, and notches can change the content rect dynamically. Poll androidContentRect() via window events to adapt your layout:
win._onWindowEvent((payload) => {
  const rect = win.androidContentRect();
  console.log('New content area:', rect);
});

Known Limitations

  • win.setProgressBar() is not implemented on Android.
  • win.setContentProtection() behaviour depends on the OEM’s WebView implementation.
  • win.setSkipTaskbar() is a no-op (Android has no taskbar).
  • Window transparency (transparent: true) requires the Activity to be configured with a transparent theme in the Android manifest; WebviewJS cannot set this at runtime.

Build docs developers (and LLMs) love