Use cases

Customer registration

Verify a new customer's mobile number while they create an account.

  1. The sign-up form collects the number with the rest of the details.
  2. Your server validates the details, then sends a code with purpose: "signup". Create the account as unverified, or keep the sign-up data in the session until the number is confirmed.
  3. Show a code box. Your server checks the code with the verification id from the session.
  4. On valid: true, set phone_verified_at on the account. Use the number the server sent the code to, not one sent by the browser.

Details that matter

  • One account per number: check that no other account owns the number before sending a code, so you don't pay to verify a number you'll refuse anyway.
  • Unverified accounts: decide what they can do (e.g. browse but not order), and remove ones that never verify.
  • Changing the number later: treat it as a new verification (phone verification), and keep the old number until the new one is confirmed.
  • Abuse: sign-up forms are public. Add a CAPTCHA or a per-IP limit before the send, so bots can't make you pay for messages to random numbers.

Code: Next.js, Laravel, Node.js, Python.

View as Markdown