On this page

Phone sign-in

Sign users in with a phone number and a one-time code sent by SMS, or with a phone number and password.

#Set up an SMS provider

In Studio → Authentication → Sign-in methods → Phone, choose your provider and enter its credentials: Twilio, Twilio Verify, MessageBird, Vonage or Textlocal. Messages are sent from your own provider account; credentials are stored encrypted and never shown again. Then turn on Enable phone sign-in.

#Sign in with a code

JavaScript
await stitchdb.auth.signInWithOtp({ phone: '+15555550100' })            // sends the SMS
const { data } = await stitchdb.auth.verifyOtp({ phone: '+15555550100', token: '123456', type: 'sms' })

#Phone and password

JavaScript
await stitchdb.auth.signUp({ phone: '+15555550100', password })
await stitchdb.auth.verifyOtp({ phone: '+15555550100', token: '123456', type: 'sms' }) // when "Confirm phone number" is on
await stitchdb.auth.signInWithPassword({ phone: '+15555550100', password })

#Settings

SettingDefaultNotes
Confirm phone numberOnNew users must enter the SMS code before they can sign in.
Code expiry / length60 s / 6 digitsUp to 24 hours and 10 digits.
SMS messageYour code is {{ .Code }}Must contain {{ .Code }}.
Minimum interval per number60 sRequests for the same number within it get 429.
SMS per hour30For the whole project.
Test phone numbers—Number = fixed code; no SMS is sent. For development and app-store reviews.

Numbers use international format (E.164), like +4915112345678. To send SMS from your own code instead, use the Send SMS hook.