Skip to Content
PlatformsCapacitor

Capacitor Plugin

For Capacitor apps on iOS and Android, we recommend the Capacitor plugin for a smoother scan experience. Your JavaScript calls the native SDK through the plugin. The native SDK captures and processes the camera frames and renders the preview.

Install the SDK

The Capacitor plugin is published to npm as @shenai/capacitor-sdk.

npm install @shenai/capacitor-sdk npx cap sync

The plugin resolves the Android SDK from Maven Central and the iOS SDK from CocoaPods during the native build.

Configure the native camera permissions and initialize the plugin before showing the preview.

WebView overlay

Capacitor displays your app’s HTML interface in a WebView. By default, the plugin places the native scan view behind it. Keep the HTML page and any containers over the scan area transparent so the camera stays visible. Touches that start inside the preview are forwarded to the SDK view.

Use setViewRect to set the preview’s position and size in platform view units. Omit width or height, or set it to zero, to fill the parent in that dimension. To place the native view above your web content instead, call setOverlaysWebview with overlay: true.

import { ShenaiSdkCapacitor } from "@shenai/capacitor-sdk" await ShenaiSdkCapacitor.setViewRect({ x: 16, y: 16, width: 240, height: 320 }) // Optional: place the preview above the WebView. await ShenaiSdkCapacitor.setOverlaysWebview({ overlay: true })

Example apps

See Configuration to choose scan settings and Preparation for guidance before a scan.

For custom frame input, see Use your own camera pipeline.