Usage
Learn how to use the Azakaw Web SDK in your application.
Authentication
The SDK does not take API credentials. Authentication is performed via a session-id issued by your backend:
- Your backend calls the Create Session endpoint with your
AppKeyand the customer details, and receives asessionId. - Your backend hands the
sessionIdto the browser (page render, API response, cookie — your choice). - You pass that
sessionIdinto the<az-customer-onboarding>element as thesession-idattribute.
Sessions can be revoked with the Invalidate Session endpoint — call it once onboarding completes so the same link cannot be reopened.
Basic Implementation
The simplest way to implement the SDK is:
<az-customer-onboarding
session-id="your-session-id"
host-origin="http://localhost:4200"
environment="Sandbox"
region="UAE"
></az-customer-onboarding>
Event Handling
You can listen for the onboarding completion event:
const onboardingElement = document.querySelector('az-customer-onboarding');
onboardingElement.addEventListener('onboardingCompleted', () => {
console.log('Customer onboarding completed');
});
Full Implementation Example
Here's a complete example showing how to integrate the SDK:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Azakaw KYC Integration</title>
</head>
<body>
<div class="container">
<az-customer-onboarding
session-id="your-session-id"
host-origin="http://localhost:4200"
environment="Sandbox"
region="UAE"
></az-customer-onboarding>
</div>
<script type="module">
// Initialize the SDK
import '@azakawcompliance/azakaw-web-sdk';
// Get reference to the element
const kycElement = document.querySelector('az-customer-onboarding');
// Handle completion
kycElement.addEventListener('onboardingCompleted', () => {
console.log('Onboarding completed successfully');
// Add your completion logic here
});
</script>
</body>
</html>
The inline script must be type="module" — a bare import in a classic script throws Uncaught SyntaxError: Cannot use import statement outside a module.
The bare specifier '@azakawcompliance/azakaw-web-sdk' is resolved by your bundler. If you are opening a plain HTML file with no build step, point the import at the bundled file instead:
import './node_modules/@azakawcompliance/azakaw-web-sdk/dist/main.js';
Layout Options
Three optional boolean attributes control how the onboarding flow is presented:
<az-customer-onboarding
session-id="your-session-id"
host-origin="http://localhost:4200"
environment="Sandbox"
region="UAE"
auto-resize="true"
hide-sidebar="true"
hide-onboarding-sections="true"
></az-customer-onboarding>
auto-resize— the iframe height is resized dynamically to match its content, so the host page does not need a fixed-height container.hide-sidebar— hides the sidebar on the onboarding page.hide-onboarding-sections— starts the user on the first page of the form; the onboarding sections page is only shown once onboarding is complete.
See the API Reference for defaults.
Best Practices
-
Initialization
- Import the SDK before using the component
- Ensure host-origin matches your application's URL
- Handle the onboardingCompleted event
-
Error Handling
- Implement error handling for session creation
- Validate session ID before initialization
- Handle network connectivity issues
-
User Experience
- Place the component in a container with appropriate sizing, or enable
auto-resize - Consider mobile responsiveness
- Implement proper loading states
- Place the component in a container with appropriate sizing, or enable
Next Steps
See the API Reference for detailed information about all available options and events.