SMS Login

SMS Login


With Magic, you can use SMS one-time codes as an authentication mechanism, giving users a simple way to log in using their phones.



This feature can only be utilized with Dedicated Wallet apps. See our FAQ's on supported country codes.

SMS Login SDK methods are available on all client-side SDKs.

#Use Cases

  • Log in and create wallets for end users with a one-time code sent by SMS to their phone number.


You can use SMS login by creating a project with our CLI tool and picking 'SMS' when prompted. Alternatively, you can directly integrate it into your existing projects using the sample below. Refer to the API documentation for information on how to install and initialize Magic for your existing project.

Once you've created a Magic instance, log users in using loginWithSMS. Once logged in, you will receive a DID token that can be used with our Admin SDK to verify the user's information and wallet address on the backend. You can also retrieve the user's wallet address and email using the user module's getInfo function for Web/React Native and getMetadata for iOS, Android and Flutter.

01// Assumes you've initialized a `Magic` instance with a Dedicated Wallet API Key
02const login = async (phoneNumber) => {
03     try {
04        const did = await magic.auth.loginWithSMS({
05          phoneNumber: phoneNumber,
06        });
07        console.log(`DID Token: ${did}`);
09        const userInfo = await magic.user.getInfo();
10        console.log(`UserInfo: ${userInfo}`);
12// Handle user information as needed
13     } catch {
14       // Handle errors as required
15     }