SmartAuth JavaScript SDK

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.

1. Include the SDK Script

<script src="https://sdk.smartauth.com.ng/smartauth-modal-sdk.js"></script>

2. Add the SmartAuth Button

<div
  class="smartauth-button"
  data-type="phone"      <!-- or "email" -->
  data-style="light"     <!-- or "dark" -->
/>

3. Define startVerification()

This function is automatically called when the user clicks the SmartAuth button.

⚠️ Important: You are responsible for generating the 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>

4. Styling Options

5. Example Button

<div class="smartauth-button" data-type="email" data-style="dark"></div>

Need Help?

Visit smartauth.com.ng or email us at support@smartauth.com.ng