The OCR (Optical Character Recognition) module handles document capture and extraction of identity information from government-issued documents. It integrates with third-party OCR providers to capture document images and extract data such as name, date of birth, document number, and expiry date.
Each provider has different capabilities, supported document types, and geographic coverage. Visit the provider’s website to understand their specific features and limitations.
Array of document configurations specifying types and countries
skipInitProcess
boolean
Skip initialization process (advanced use)
Documents Array Structure:
documents: [ { type: 'DRIVERS_LICENCE', // Document type countries: ['AUS', 'NZL'] // ISO country codes (optional) }]
Daon provider: The documents parameter and document selection are not required when using the Daon provider — Daon provides its own document type selection screen. To use custom document selection instead of Daon’s built-in screen, contact your FrankieOne account team.
CSS selector string (e.g., '#ocr-container') or HTMLElement object where the component will be mounted
Description:
Mounts the OCR component to the specified DOM element. After mounting, call start() to begin the document capture process.Example:
// Mount to element by ID - capture begins automaticallyocrComponent.mount('#ocr-container');// Mount to element referenceconst container = document.getElementById('ocr-container');ocrComponent.mount(container);
Legacy Method: This method is for headless OCR integration and is not recommended for standard use. Modern provider integrations handle the capture flow automatically after mounting. Avoid using this method unless you have a specific headless integration requirement.
Starts the document capture process in headless mode.Signature:
start(): void
Description:
Initiates the document capture flow for headless OCR implementations. For standard provider integrations, the capture flow begins automatically when mounting.
Unmounts the OCR component from the DOM.Signature:
unmount(): void
Description:
Removes the OCR component from the DOM and cleans up resources. Call this when the user navigates away or document capture is complete.Example:
Not typically used:isPreloaded() is not used in standard OCR integrations and can be safely ignored. Use events (detection_complete, results) to track document capture progress instead. This method was designed for legacy headless OCR flows.
Checks if OCR data has been previously captured for this entity.Signature:
isPreloaded(): boolean | null
Returns:boolean | null - true if OCR data exists for this entity, false if not, null if unable to determineDescription:
Returns true if the entity has existing OCR/document data in local state. This method was designed for headless integrations where you need to check local state before rendering capture UI.For standard provider integrations, document capture status should be determined by:
Using the results event to receive capture completion status
Querying your backend API for document verification results
Checking entity status through the FrankieOne API
Example:
// ✅ Use events to track capture progressocrComponent.on('results', ({ document }) => { console.log('Document captured:', document); proceedToNextStep();});ocrComponent.mount('#ocr-container');// Capture begins automatically
This method only checks for the presence of document data in local state, not the actual verification result. Always verify document status through your backend API before proceeding with verification workflows.
Legacy Method: This method is for headless OCR integration and is not recommended for standard use. For standard provider integrations, use events to track document capture progress instead of polling status. Avoid using this method unless you have a specific headless integration requirement.
Accesses reactive data accessors for the OCR component state.Signature:
access(fieldName: 'status'): Accessor
Description:
Provides access to internal OCR status for headless implementations. For standard provider integrations, listen to events (detection_complete, results, etc.) instead of polling status.
Object containing all possible OCR status constants.Type:Readonly<typeof OCRStatus>Description:
Provides access to OCR status enum values for comparison in event handlers and status checks.Available Statuses:
Provider-Specific: Not all statuses are used by all providers. The specific statuses emitted depend on your chosen provider’s workflow and capabilities.
Status
Value
Description
WAITING_OCR_RUN
'AWAITING_DOCUMENT_OCR'
Waiting for OCR processing to run
WAITING_BACK
'AWAITING_DOCUMENT_UPLOAD_BACK'
Waiting for back side of document
WAITING_FRONT
'AWAITING_DOCUMENT_UPLOAD_FRONT'
Waiting for front side of document
COMPLETE
'COMPLETE_OCR'
OCR capture and processing complete
DOCUMENTS_INVALID
'AWAITING_DOCUMENT_UPLOAD_INVALID_TYPE'
Invalid document type provided
DOCUMENTS_UPLOAD_FAILED
'AWAITING_DOCUMENT_UPLOAD_FAILED_OCR'
Document upload failed
PROVIDER_OFFLINE
'AWAITING_OCR_RESULTS_PROVIDER_OFFLINE'
OCR provider is offline/unavailable
FAILED_FILE_SIZE
'DOCUMENT_INVALID_EXCEEDED_SIZE_LIMIT'
File size exceeds limit
FAILED_FILE_FORMAT
'DOCUMENT_INVALID_INCORRECT_FILE_FORMAT'
Incorrect file format
INTERRUPTED
'INTERRUPTED'
Capture flow was interrupted (provider-specific)
Example:
const ocrComponent = sdk.component('ocr', { provider: { name: 'onfido' } });ocrComponent.on('input_required', (info, status) => { if (status === ocrComponent.statuses.WAITING_FRONT) { console.log('Please capture front of document'); } else if (status === ocrComponent.statuses.WAITING_BACK) { console.log('Please capture back of document'); }});ocrComponent.on('results', ({ document }) => { const status = ocrComponent.access('status').getValue(); if (status === ocrComponent.statuses.COMPLETE) { console.log('OCR completed successfully'); console.log('Extracted data:', document); }});
The OCR module emits events throughout the document capture lifecycle.
Provider-Specific Behavior: Events and statuses vary by provider. Not all providers emit all events, and some events are provider-specific. Always test with your chosen provider to understand which events are emitted and when.
Description:
This event indicates that document capture cannot proceed in its current state, but the issue is typically recoverable. Common scenarios include:
Waiting for front or back side of document
User needs to retry capture
Document type mismatch
Legacy Parameter: The provideFile callback is for headless OCR integration and is not recommended for standard use. For standard provider integrations, the provider handles file capture automatically. Avoid using this parameter unless you have a specific headless integration requirement.
Example:
ocrComponent.on('input_required', (info, status) => { console.log('Input required:', { documentType: info.documentType, side: info.side, status: status }); if (status === ocrComponent.statuses.WAITING_FRONT) { showMessage('Please capture the front of your document'); } else if (status === ocrComponent.statuses.WAITING_BACK) { showMessage('Please capture the back of your document'); }});
Description:
Contains the extracted document information including ID number, expiry date, date of birth, and other fields depending on document type. The document structure matches the Document Structure used in the Individual module.Example:
Legacy Headless OCR: This event is primarily used in legacy headless OCR implementations. For standard provider integrations, use the results event instead.
Handle all events, not just results - Also listen to input_required (for recoverable states like WAITING_FRONT, WAITING_BACK, DOCUMENTS_INVALID), detection_failed (for capture failures), and error (for system failures).
Set up event listeners before mounting - Register all event handlers before calling mount() to avoid missing events.
Unmount on navigation - Always call unmount() when the user leaves the page to clean up resources.
Provider-specific configuration - Review each provider’s documentation for optimal configuration.
Error handling - Always listen to the error event and provide user-friendly error messages.