# Phone sign-in with SMS

> Let users sign in to a SupaHost project with a one-time code sent by SMS, using your own Twilio, Twilio Verify, MessageBird, Textlocal or Vonage account. Setup, settings, test numbers and client code.

Source: https://supahost.app/docs/auth/phone-login · Updated 2026-11-11

Phone sign-in lets users sign up and sign in with their phone number. Auth sends a one-time code by SMS, the user types it into your app, and they're signed in. Users can also sign up with a phone number and a password.

SMS costs money per message, so SupaHost doesn't send SMS for you. You connect your own SMS provider account, and messages are billed by that provider. The same provider is also used for [phone MFA](/docs/auth/mfa).

## Supported providers

| Provider | What you enter |
|---|---|
| Twilio | Account SID, Auth token, Messaging Service SID or phone number. Optional: Content SID, for sending codes over WhatsApp |
| Twilio Verify | Account SID, Auth token, Verify Service SID |
| MessageBird (Bird) | Access key, Originator |
| Textlocal | API key, Sender |
| Vonage | API key, API secret, From |

Create the account and the sender (number, messaging service or sender name) in the provider's console first. Rules for sender names and numbers differ by country, so check the provider's guidance for the countries your users are in.

## Set it up

Open *Dashboard → your project → **Auth** tab → **Phone sign-in (SMS)***, then:

1. Switch on **Enable phone sign-in**.
2. Pick your **SMS provider** and fill in its fields. Secrets (auth tokens, access keys, API secrets) are stored encrypted and never shown again. Leave the secret field empty later to keep the saved one.
3. Adjust the settings below if the defaults don't suit you.
4. Click **Save phone settings**.

The change reaches your project within about a minute. Only the instance owner can change these settings; team members see them read-only.

## Settings

| Setting | What it does | Default |
|---|---|---|
| SMS message | The text of the SMS. Must include `{{ .Code }}`, which is replaced by the code | `Your code is {{ .Code }}` |
| Code lifetime | Seconds before a code expires (30 to 86400) | 60 |
| Code length | Digits in the code (6 to 10) | 6 |
| Minimum gap per user | Seconds before the same number can get another code | 60 |
| SMS per hour | Project-wide limit on SMS sent by Auth. Protects your provider bill | 30 |
| Skip phone confirmation | Lets new phone users sign in before they confirm their number. Not recommended | Off |
| Test phone numbers | Numbers that always accept a fixed code, with no SMS sent (see below) | None |

A 60-second code lifetime is short for users who switch apps to read the SMS. If you see many expired-code errors, raise it to a few minutes.

## Sign in with a code

Phone numbers are in international format, with the country code.

```ts
// 1. Send the code
const { error } = await supabase.auth.signInWithOtp({
  phone: '+447700900123',
})

// 2. Verify the code the user typed
const { data, error: verifyError } = await supabase.auth.verifyOtp({
  phone: '+447700900123',
  token: codeFromInput,
  type: 'sms',
})
// data.session is the signed-in session
```

`signInWithOtp` creates the user if the number isn't registered yet. To allow only existing users, pass `options: { shouldCreateUser: false }`.

## Sign up with a phone and password

```ts
const { error } = await supabase.auth.signUp({
  phone: '+447700900123',
  password: 'a-long-passphrase',
})

// Confirm the number with the code from the SMS
await supabase.auth.verifyOtp({ phone: '+447700900123', token: codeFromInput, type: 'sms' })

// Later sign-ins
await supabase.auth.signInWithPassword({ phone: '+447700900123', password: 'a-long-passphrase' })
```

## Test phone numbers

App store reviewers and automated tests need to sign in without a real SIM. In **Test phone numbers**, add one entry per line as `number=code`, using digits only:

```
447700900001=123456
447700900002=654321
```

Those numbers always accept that code, and no SMS is sent. You can add up to 20. Use numbers you don't own and that real users can't have, such as ranges reserved for drama or testing in your country, and remove them if you no longer need them.

Test numbers only cover phone sign-in (`signInWithOtp` and `verifyOtp`). Phone MFA challenges always send a real SMS through your provider.

## Limits and costs

- **SMS per hour** applies to the whole project. When it's used up, Auth returns a `429` error until the hour rolls over. Set it to what your busiest hour needs, and no higher, so a script can't run up your provider bill.
- **Minimum gap per user** stops repeat requests for the same number. Show a countdown on your "resend code" button that matches it.
- Your provider may also block or rate limit messages to some countries. Many providers let you allow only the countries you serve, which is a good defence against SMS pumping fraud.

See [Auth rate limits](/docs/auth/rate-limits) for the other limits.

## Users and the database

Phone users are ordinary Auth users. The number is in `auth.users.phone`, and `phone_confirmed_at` is set once they verify a code. RLS works the same: `auth.uid()` is the user's ID.

A user can have both an email and a phone number. To add a phone to a signed-in user, call `supabase.auth.updateUser({ phone })`, then verify with `verifyOtp({ phone, token, type: 'phone_change' })`.

## Related

- [Multi-factor authentication](/docs/auth/mfa)
- [Magic links and email OTP](/docs/auth/magic-links-otp)
- [OTP or magic link "token has expired"](/kb/otp-expired)
