Usage
Add the component
After installation and necessary imports:
Add the desired images capture markup to your page/component:
<selfie-capture-screens></selfie-capture-screens><document-capture-screens></document-capture-screens><smart-camera-web capture-id></smart-camera-web>For basic color theming, add the theme-color attribute to the component with a valid css hex value
<smart-camera-web theme-color="#7AAAFA"></smart-camera-web>Selfie Capture
Initially, you'll see this instruction screen (unless this is turned off), guiding the user on best practices for good selfie capture, this will be followed by the selfie capture screen prompting the user to present their face and a review screen:



To turn off the instruction screen, add the hide-instructions attribute to the component
Document Capture
If the capture-id attribute is used, you will be presented with additional screens for document capture (front, back (optional by adding hide-back-of-id attribute), review):



Capture front of document only
Handle events
Handle the smart-camera-web.publish event:
When the user approves the captured image, a smart-camera-web.publish event is dispatched. The event returns a CustomEvent payload in e.detail.
Here's a script example to handle the event and send data to a backend endpoint:
Note: when using the selfie-capture-screens listen to the selfie-capture-screens.publish event to get the selfie and liveness images.
For document-capture-screens listen to the document-capture-screens.publish event for the document image.
More details here
Process request on backend
The provided backend endpoint uses the NodeJS Server to Server library and ExpressJS:
This approach can also be achieved using other Server to Server libraries.
Handling Events
Selfie and liveness images
To receive the images after they have been captured, you can listen to the custom event selfie-capture-screens.publish. The data posted to this event has the structure:
Handling the publish event:
Handling the cancel event
Handling the back event
Document image
Capture events emit document-capture-screens.publish, providing captured images and metadata:
Handling the publish event
Handling the cancel event
Handling the back event
Compatibility
SmartCameraWeb is compatible with most JavaScript frameworks and libraries. For integration with ReactJS, refer to this tutorial due to React-WebComponents compatibility issues.
Please see the trouble shooting guide here for situations where the camera is not loading.
Support
Tested on the latest versions of Chrome, Edge, Firefox, and Safari. If compatibility issues arise on certain browsers, please notify us.
Last updated
Was this helpful?

