Installing the React Native Document Scanner SDK
To install the SDK, run the following in your root project folder:
- npm
- Yarn
- Expo
npm install react-native-scanbot-sdk
yarn add react-native-scanbot-sdk
npx expo install react-native-scanbot-sdk
Android
Since your application will work with high-resolution images, we strongly recommended to add the property android:largeHeap="true" in the <application> element of your android/app/src/main/AndroidManifest.xml file, especially for Android <= 7.x.
Processing high-resolution images is a memory-intensive task and this property will ensure your app has enough heap allocated to avoid OutOfMemoryError exceptions.
<application ... android:largeHeap="true">
...
</application>
Integration with Expo
Integration with Expo is possible only when using a Development Build, not Expo Go. The project is configurable using our config plugin or by manually configuring the native projects.
To utilize the plugin, add the following in your app config file:
"plugins": [
[
"react-native-scanbot-sdk",
{
"iOSCameraUsageDescription": "Document & Barcode Scanning permission",
"largeHeap": true,
"mavenURLs": true,
"ocrBlobsDirPath": "./ocr_blobs",
"addTesseractGradleDependency": false,
"podfileSPMHookEnabled": false
}
]
],
iOSCameraUsageDescription: AddsNSCameraUsageDescriptionin Info.plist. The permission can also be added via Expo Permissions.largeHeap: Addsandroid:largeHeapproperty in<application>element in AndroidManifest.xml.mavenURLs: Adds Scanbot SDK Maven URLs for Android local development. These URLs are already included in the package's build.gradle, but need to be added due to how Expo starts the Android app.ocrBlobsDirPath: Addsocr_blobsfor Android and iOS. Specify a path of a directory that contains only.traineddatafiles.- For Android, the files are copied over from the specified path in android/app/src/main/assets/ocr_blobs.
- For iOS, a
ScanbotSDKOCRData.bundleis created and added as a resource, and the files are copied over from the specified path.
addTesseractGradleDependency: Adds the Tesseract OCR Gradle dependency for Android. This is required if you want to use the TESSERACT OCR features of the SDK.podfileSPMHookEnabled: Adds a hook to your Podfile that enables Swift Package Manager (SPM) support on older React Native versions. Defaults totrue. Set it tofalseto use CocoaPods instead. On React Native 0.87 or newer, you can remove this hook from your Podfile.
For more details about OCR, please refer to the OCR section.
iOS SPM Support
The CocoaPods trunk repo is being deprecated, so the Scanbot iOS SDK is installed through Swift Package Manager (SPM) by default. React Native 0.87+ supports SPM out of the box, so no additional configuration is needed for these versions.
Podfile hook
For React Native < = 0.86, add the scanbot_spm hook to the post_install block of your Podfile:
post_install do |installer|
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false,
)
scanbot_spm(installer)
end
Opting out of SPM (CocoaPods fallback)
You can opt out and use the CocoaPods dependency instead. This only applies for versions that have a CocoaPods fallback.
Bare React Native projects
To install the Scanbot iOS SDK through CocoaPods instead, set the $ScanbotSDKUseSPM flag to false at the top level of your Podfile,
before the first target block:
$ScanbotSDKUseSPM = false
target 'MyApp' do
# ...
end
With the flag set, the scanbot_spm hook skips its work, so you can leave it in post_install.
Run pod install again after changing the flag.
Expo
The Scanbot config plugin always adds the scanbot_spm hook to your Podfile. To opt out of SPM, set podfileSPMHookEnabled to false in the plugin config.
The plugin then also adds $ScanbotSDKUseSPM = false to your Podfile, and the hook skips its work.
{
"plugins": [
[
"react-native-scanbot-barcode-scanner-sdk",
{ "podfileSPMHookEnabled": false }
]
]
}
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get free trial licenseScanbot SDK is part of the Apryse SDK product family
A mobile scan is just the start. With Apryse SDKs, you can expand mobile workflows into full cross‑platform document processing. Whether you need to edit PDFs, add secure digital signatures, or use a fast, customizable document viewer and editor, Apryse gives you the tools to build powerful features quickly.
Learn more
