How websitebeaver/react-native-document-scanner-plugin works
This React Native plugin opens a native document scanner and returns captured page images as file paths or, where supported, base64 data, with success or cancellation status. The main workflow is JavaScript API call → native module → platform scanner → image results. Android also supports a page limit; the Expo config plugin adds the iOS camera usage description. The sampled sources show Android and iOS handling, but do not expose the full iOS scanner implementation or generated native-module wiring.
Main entry points: DocumentScannerModule.kt Scan handler · DocumentScanner.swift Scan handler · NativeDocumentScanner.ts Native module spec · index.tsx Scanner API
Components 12
JavaScript API
- Scanner API
src/index.tsx - Native module spec
src/NativeDocumentScanner.ts
Android Scanner
- Module registration
android/src/main/java/com/documentscanner/DocumentScannerPackage.kt - Scan handler
android/src/main/java/com/documentscanner/DocumentScannerModule.kt - ML Kit scanner
- Page results
android/src/main/java/com/documentscanner/DocumentScannerModule.kt
iOS Scanner
- Scan handler
ios/DocumentScanner.swift - Document scanner
ios/DocScanner - Scan response
ios/DocumentScanner.swift
App Configuration
- Expo config plugin
expo-plugin/src/withDocumentScanner.ts
Other components
- React Native app
- iOS app config
Connections 13
- React Native app → Scanner API: calls
README.md - Scanner API → Native module spec: delegates to
src/index.tsx - Native module spec → Scan handler: dispatches to
- Module registration → Scan handler: creates
android/src/main/java/com/documentscanner/DocumentScannerPackage.kt - Scan handler → ML Kit scanner: launches
android/src/main/java/com/documentscanner/DocumentScannerModule.kt - ML Kit scanner → Scan handler: returns pages
android/src/main/java/com/documentscanner/DocumentScannerModule.kt - Scan handler → Page results: resolves
android/src/main/java/com/documentscanner/DocumentScannerModule.kt - Native module spec → Scan handler: dispatches to
- Scan handler → Document scanner: starts scan
ios/DocumentScanner.swift - Document scanner → Scan handler: returns images
ios/DocumentScanner.swift - Scan handler → Scan response: resolves response
ios/DocumentScanner.swift - React Native app → Expo config plugin: configures
- Expo config plugin → iOS app config: sets camera usage
expo-plugin/src/withDocumentScanner.ts