Scan in real time via camera
BlinkID includes a built-in scanning UI that manages the camera feed, guides the user with real-time feedback, and returns extracted data via a result callback. The camera stream starts automatically once scanning is initialized—no additional setup is required.
Embed the scanning UI
By default, the scanning UI covers the full screen.
On web, pass targetNode to render it inside a specific element instead.
- Web (TS)
- Android (Kotlin)
- iOS (Swift)
import { createBlinkId } from "@microblink/blinkid";
const container = document.getElementById("scanner-container");
const blinkId = await createBlinkId({
licenseKey: "your-license-key",
targetNode: container ?? undefined,
});
blinkId.addOnResultCallback((result) => {
console.log("First name:", result.firstName?.latin?.value);
console.log("Document number:", result.documentNumber?.latin?.value);
void blinkId.destroy();
});
BlinkIdCameraScanningScreen(
blinkIdSdk = blinkIdSdk,
onScanningSuccess = { result ->
println("First name: ${result.firstName?.value}")
println("Document number: ${result.documentNumber?.value}")
},
onScanningCanceled = { }
)
let analyzer = try await BlinkIDAnalyzer(sdk: sdk)
BlinkIDUXView(
analyzer: analyzer,
onScanCompleted: { resultState in
guard let result = resultState.scanningResult else { return }
print("First name:", result.firstName?.value ?? "")
print("Document number:", result.documentNumber?.value ?? "")
}
)
Skip the onboarding guide
By default, BlinkID shows an onboarding guide before scanning begins. Disable it to start frame capture immediately when the camera is ready.
- Web (TS)
- Android (Kotlin)
- iOS (Swift)
import { createBlinkId } from "@microblink/blinkid";
const blinkId = await createBlinkId({
licenseKey: "your-license-key",
feedbackUiOptions: {
showOnboardingGuide: false,
},
});
blinkId.addOnResultCallback((result) => {
console.log("Result:", result);
void blinkId.destroy();
});
BlinkIdCameraScanningScreen(
blinkIdSdk = blinkIdSdk,
uiSettings = UiSettings(showOnboardingDialog = false),
onScanningSuccess = { result ->
// use result
},
onScanningCanceled = { }
)
let analyzer = try await BlinkIDAnalyzer(sdk: sdk)
BlinkIDUXView(
analyzer: analyzer,
onScanCompleted: { resultState in
guard let result = resultState.scanningResult else { return }
print("Result:", result)
}
)
.uxSettings(ScanningUXSettings(showIntroductionAlert: false))
Handle errors
Register an error callback to handle failures during scanning.
- Web (TS)
- Android (Kotlin)
- iOS (Swift)
import { createBlinkId } from "@microblink/blinkid";
const blinkId = await createBlinkId({
licenseKey: "your-license-key",
});
blinkId.addOnResultCallback((result) => {
console.log("Result:", result);
void blinkId.destroy();
});
blinkId.addOnErrorCallback((error) => {
console.error("Scanning error:", error);
void blinkId.destroy();
});
// onScanningCanceled is called both when the user cancels and when scanning fails
BlinkIdCameraScanningScreen(
blinkIdSdk = blinkIdSdk,
onScanningSuccess = { result ->
println("First name: ${result.firstName?.value}")
},
onScanningCanceled = {
println("Scanning canceled or failed")
}
)
// scanningResult is nil when scanning ends without a result (canceled or failed)
BlinkIDUXView(
analyzer: analyzer,
onScanCompleted: { resultState in
guard let result = resultState.scanningResult else {
print("Scanning canceled or failed")
return
}
print("First name:", result.firstName?.value ?? "")
}
)
Clean up
On Android and iOS, the scanning UI component owns its own lifecycle and releases camera resources automatically.
On web, call destroy() explicitly when scanning is complete or the user cancels.
- Web (TS)
- Android (Kotlin)
- iOS (Swift)
blinkId.addOnResultCallback((result) => {
console.log("Result:", result);
void blinkId.destroy();
});
No explicit cleanup is needed. The composable releases all camera resources when it leaves the composition.
No explicit cleanup is needed. The view releases all camera resources when it is dismissed.
To use the front-facing camera for kiosk-style setups where the user holds the document up to the screen, see How to use the front-facing camera.