StoreOSv0.15.0
Guides

Phone OTP Auth

Passwordless customer login with SMS — how OTP auth works on StoreOS.

What phone OTP is

OTP (one-time password) lets customers sign in with their phone number instead of email and password. StoreOS sends a 4-digit SMS code; the customer enters it to get a JWT session.

Best for: Mobile-first storefronts in Bangladesh and markets where phone is the primary identity.


How it works

1. Customer enters phone     →  sendOtp
2. SMS with 4-digit code     →  (StoreOS + SMS provider)
3. Customer enters code      →  verifyOtp
4. accessToken returned      →  your app saves token
5. Customer is signed in     →  getMe, getMyOrders, etc.

New customers: sendOtp returns isNewCustomer: true — show a name field on verify.
Returning customers: verify with phone + OTP only.


SDK implementation

import { store } from "@/lib/store";

// Step 1 — send code
const { isNewCustomer } = await store.sendOtp({
  phoneNumber: "+8801XXXXXXXXX",
});

// Step 2 — verify (show name field if isNewCustomer)
const { accessToken, user } = await store.verifyOtp({
  phoneNumber: "+8801XXXXXXXXX",
  otp: "1234",
  name: isNewCustomer ? "Jane Doe" : undefined,
});

// Step 3 — persist session in YOUR app
const token = store.getAccessToken();
// → cookie, localStorage, etc.

GraphQL equivalent

mutation SendOtp($input: SendOtpInput!) {
  sendOtp(input: $input) { success message isNewCustomer }
}

mutation VerifyOtp($input: VerifyOtpInput!) {
  verifyOtpToLogin(input: $input) {
    accessToken
    user { _id name phoneNumber }
  }
}

Field is phoneNumber (E.164 format, e.g. +8801…).


REST equivalent

StepRoute
SendPOST /api/v1/auth/otp/send
VerifyPOST /api/v1/auth/otp/verify

REST auth


Your app's responsibilities

TaskWho
Phone input UIYour app
OTP input UI (4 digits)Your app
Name field for new usersYour app
Save accessTokenYour app
Send SMSStoreOS

OTP-only accounts get a random password server-side — customers never need to know it.


Typical page: /auth/phone

  1. Form with phone number → call sendOtp
  2. OTP input (4 boxes or single field) → call verifyOtp
  3. If new user, name input before verify
  4. On success, redirect to previous page or /dashboard

Auth overview · SDK methods

On this page