KYC Element
createElement('kyc', options?)
Parameters
type
required'kyc'options
optionalKycElementOptionskyc Element.hideHeader
optionalbooleanlocale
optional'en' | 'zh' | 'fr'The locale for the Element, applied to Element UI strings and error messages. By default, the locale configured in init() is used.
The provided locale must be supported by the onboarding business’s registration country. For example, ‘fr’ is supported if the business is registered in Canada or an EU country.
For a full list of supported locales by country, see customization options.
Controls how the application progress tracker is displayed. When set, takes precedence over hideNav.
side(default): Shows a vertical navigation bar on the left-hand side.floating: Shows a compact, collapsible navigation at the top (recommended for mobile).none: Hides the navigation entirely.
ts
'side'Hides the application progress tracker when set to true. When set to false or omitted, the tracker is shown using a vertical navigation bar on the left-hand side.
Note: hideNav is deprecated. Use navLayout instead to control how the application progress tracker is displayed.
If both navLayout and the legacy hideNav field are provided, navLayout takes precedence and hideNav is ignored. This ensures the new configuration is always applied consistently.
The values are migrated as follows:
- When hideNav is set to true, navLayout: none
- When hideNav is set to false, navLayout: side or floating, depending on your preferred layout.
langKey
optional'en' | 'zh' | 'fr'Deprecatedlocale instead.Returns
KycElement | null
1import { createElement } from '@airwallex/components-sdk';23const element = await createElement('kyc', {4 hideHeader: true,5 hideNav: true,6});
destroy()
1element.destroy();
mount(domElement)
Parameters
domElement
requiredstring | HTMLElement1// There are two ways to mount element:2// 1. Call with container DOM id3element.mount('container-dom-id');45// 2. Find the created DOM in existing HTML and call with container DOM element6const containerElement = document.getElementById('container-dom-id');7element.mount(containerElement);
on('ready', handler)
This event will be fired when:
- Consent page is ready, if it is enabled. The
typein event data will beconsent. Use this event to decide when to remove loading status from your page. - KYC page is ready. The event data will contain
kycStatus, which represents the account's onboarding status. UsekycStatusto render your own status pages and handle re-entry scenarios.
Parameters
type
required'ready'handler
requiredfunction1type kycEventData = {2 type: 'kyc',3 kycStatus: 'INIT' | 'SUBMITTED' | 'SUCCESS' | 'FAILURE'4 };56 type consentEventData = {7 type: 'consent'8 };910 element.on('ready', (data: kycEventData | consentEventData) => {11 console.log('KYC ready:', data.type);12 });
on('success', handler)
Parameters
type
required'success'handler
required() => void1element.on('success', () => {2 // Handle success event3});
on('cancel', handler)
Parameters
type
required'cancel'handler
required() => void1element.on('cancel', () => {2 console.log('KYC cancelled');3});
on('error', handler)
Parameters
type
required'error'handler
requiredfunctionThe callback function that will be called when the event occurs.
The handler receives an object with the following properties:
code
required'API_ERROR' | 'SUBMIT_FAILED'message
optionalstring1type errorCode = 'API_ERROR' | 'SUBMIT_FAILED' | 'UNKNOWN';2type ErrorData = { code: errorCode, message?: string }34element.on('error', (data: ErrorData) => {5 console.error('KYC error:', data.code, data.message);6});
unmount()
1element.unmount();