Skip to content
Alchemy Logo

SMS Authentication

SMS auth is currently in closed alpha. If you'd like early access please reach out to [email protected].

Authenticate users with their phone number by sending verification codes via SMS.

SMS authentication is a two-step process:

  1. Send the verification code: the user enters their phone number and requests a verification code.
  2. Submit the verification code: the user enters the 6-digit code they receive via SMS to complete authentication.

The SDK will handle phone number validation, code generation, and delivery automatically.

We support all major countries across Europe, Asia, North and South America.

Pricing varies by country and requires specific area codes to be enabled for your account.

SMS auth is not yet supported with pre-built UI components. Please follow this guide to set up custom UI and configure authentication with hooks.

Ensure you pass the phone number including the country code in the format +<country code><phone number> (i.e. `+15553219876).

import { useAuthenticate } from "@account-kit/react"
 
const { authenticate } = useAuthenticate()
 
const handleSendCode = (phone: string) => {
    authenticate(
        { type: "sms", phone: "+123456789" },
        {
            onSuccess: () => {
                // onSuccess only fires once the entire flow is done (SMS OTP + optional MFA).
                // It still runs even if the final step completes in another tab/window.
            },
            onError: (error) => {
                // Handle error
            },
        },
    );
};

Use the useSignerStatus hook to show the otp input once the code is sent:

import React from "react";
import { useSignerStatus } from "@account-kit/react";
import { AlchemySignerStatus } from "@account-kit/signer";
 
const TrackStatus = () => {
const { status } = useSignerStatus();
 
return (
    <>
        {status === AlchemySignerStatus.AWAITING_SMS_AUTH && (
            <div>Prompt the user to enter the OTP code received via SMS</div>
        )}
    </>
);
};

import { useAuthenticate } from "@account-kit/react";
 
const { authenticate } = useAuthenticate();
 
// When the user submits the OTP code
const handleVerifyCode = (otpCode: string) => {
    authenticate(
        {
            type: "otp",
            otpCode,
        },
        {
            onSuccess: () => {
                // onSuccess only fires once the entire flow is done (SMS OTP).
            },
            onError: (error) => {
                // Handle invalid code error
            },
        },
    );
};

Use the useSignerStatus hook we set up before to wait until the user is authenticated:

import { useSignerStatus } from "@account-kit/react";
 
// Inside your component
const { isConnected } = useSignerStatus();
 
// You can use isConnected to conditionally render UI

Was this page helpful?