Embed phone or email verification into your web app using SmartAuth’s SDK. This guide helps you integrate the modal into your frontend using a simple JavaScript snippet.
<script src="https://sdk.smartauth.com.ng/smartauth-modal-sdk.js"></script>
<div
class="smartauth-button"
data-type="phone" <!-- or "email" -->
data-style="light" <!-- or "dark" -->
/>
startVerification()This function is automatically called when the user clicks the SmartAuth button.
verificationId by making a secure call to your own backend. Your backend should call the SmartAuth API (/get-verification-link) and return the verificationId to your frontend.
<script>
async function startVerification() {
const res = await fetch('/api/create-verification', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'phone', // or "email"
phone: '+2348012345678'
})
});
const { verificationId } = await res.json();
SmartAuth.init({
verificationId,
onComplete: ({ token, request_id }) => {
console.log("✅ Verified!", token, request_id);
// You can now send this to your backend
}
});
}
window.startVerification = startVerification;
</script>
data-style="light": White background with green borderdata-style="dark": Green background with white text<div class="smartauth-button" data-type="email" data-style="dark"></div>
Visit smartauth.com.ng or email us at support@smartauth.com.ng