DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

Better Auth Phone Numbers With a Five-Line OTP Adapter

Better Auth's sendOTP callback handles SMS delivery, while verifyOTP replaces the plugin's internal verification. Here is how the five-line adapter fits, what to supply yourself, and the documented defaults.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In Better Auth’s Phone Number plugin, the sendOTP callback is the delivery hook. It receives the destination phone number and the generated code, and your application passes them to an SMS provider. Verification stays inside the plugin unless you also supply verifyOTP, which replaces that internal check. A five-line adapter therefore handles sending only, and it does not verify anything.

How the plugin is wired

The Phone Number plugin is imported as phoneNumber from better-auth/plugins and added to the plugins array in your Better Auth configuration, as described in the current Phone Number plugin documentation. The plugin owns the request logic, and your callbacks own message delivery and, if you choose, verification.

As an Amazon Associate I earn from qualifying purchases.

The five-line sendOTP adapter

The snippet below shows the shape of the integration. It is illustrative only. It has not been run or tested, sms is a placeholder for your provider client, and it omits credentials, error handling, and background execution.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
phoneNumber({
  sendOTP: ({ phoneNumber, code }) => sms.send({ to: phoneNumber, body: `Code: ${code}` }),
})

The callback destructures two values. phoneNumber is the destination, and code is the one-time code the plugin generated. The documented callback also receives a second context argument, which this snippet does not use. Confirm the exact callback types against the Better Auth version installed in your project.

#1 Best Overall
Yubico - Security Key C NFC - Basic Compatibility - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key C NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key C NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key C NFC via USB-C and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.

What your application must supply

  • A real provider call. Replace the placeholder with your SMS provider’s SDK or HTTP call, and write the message template yourself.
  • Credentials from secure configuration. Keep provider keys in environment variables or secret storage, not in source files.
  • Error handling. The snippet discards the provider’s result. Decide whether a failed send is logged, retried, or surfaced in some other way.
  • Background execution where needed. On serverless platforms, the send may need the runtime’s background-task mechanism, covered below.

Why the callback should not be awaited

The documentation is direct on this point: “We highly recommend not awaiting the sendOTP function. If you await it, it’ll slow down the request and could cause timing attacks.” (Better Auth documentation, Phone Number plugin page; the page does not name an individual author.)

Not awaiting the send keeps the authentication response from waiting on the provider, and it keeps response timing from reflecting whether a send happened. The cost is that a failed send no longer blocks the request. If you do not handle the promise, a rejection can go unnoticed, so add your own logging or failure handling inside the callback.

Rank #2
Yubico - YubiKey 5C NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified - Protect Your Online Accounts
  • POWERFUL SECURITY KEY: The YubiKey 5C NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
  • WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5C NFC secures 100+ of your favorite accounts, including email, password managers, and more
  • FAST & CONVENIENT LOGIN: Plug in your YubiKey 5C NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
  • MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
  • PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts

On serverless platforms, the docs mention waitUntil as an option to make sure delivery finishes after the response has been returned. Use the background-task API your platform provides for that purpose.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

verifyOTP replaces verification; it does not add delivery

The verifyOTP callback receives phoneNumber and code and returns a boolean or a promise that resolves to one. When you configure it, Better Auth uses it instead of its internal verification logic. It is a custom verifier, not a second sending path. Sending an SMS and checking a code are separate responsibilities, and configuring one does not configure the other.

Rank #3
Yubico - YubiKey 5 NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-A or NFC, FIDO Certified - Protect Your Online Accounts
  • POWERFUL SECURITY KEY: The YubiKey 5 NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
  • WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5 NFC secures 100+ of your favorite accounts, including email, password managers, and more
  • FAST & CONVENIENT LOGIN: Plug in your YubiKey 5 NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
  • MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
  • PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts

The documentation names Twilio Verify and AWS SNS as examples of external integrations. Its example code for these is illustrative only, so treat it as a pattern rather than a verified integration.

Question Built-in verification (sendOTP only) Custom verifyOTP
Who generates the code The plugin generates it and passes it to sendOTP Not stated in the documentation reviewed; the plugin still passes its generated code to sendOTP
Where verification happens Inside Better Auth In your verifyOTP function, which replaces the internal logic
Expiry and attempt limits Documented defaults of 300 seconds and 3 attempts (see below) Not stated in the documentation reviewed; check the expiry and attempt rules of your verifier
Single-use under parallel redemption Not stated in the documentation reviewed For strict single-use acceptance, the docs say to use a provider that atomically consumes accepted codes
Effect on delivery Set by your sendOTP callback None; verifyOTP sends nothing

Documented defaults and attempt limits

The current Phone Number documentation and the v1.6 Phone Number page both list the following defaults. Treat them as documented defaults and confirm them against the version installed in your project.

Rank #4
Yubico - Security Key NFC - Basic Compatibility - Multi-Factor Authentication (MFA) Key, Connect via USB-A or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key NFC via USB-A and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.
Option Documented default Meaning
otpLength 6 Number of digits in the code
expiresIn 300 seconds How long a code remains valid after it is issued
allowedAttempts 3 Verification attempts allowed before the code is discarded

After the allowed attempts are exceeded, the OTP is deleted and the user must request a new one. Build your interface to handle that case, because a user who mistypes the code three times will need to start over.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Schema changes

The plugin schema requires two user fields, phoneNumber and phoneNumberVerified. Add them before testing any sign-in flow.

Best Value
FIDO2 U2F Security Key Passkey Two-Factor Authentication (2FA) USB Key PIN+Touch (Non-Biometric) USB-A Type TrustKey T110
  • Security Key : Protect your online accounts against unauthorized access by using FIDO2 and U2F authentication with T110. It's the world's most protective security key that works with windows, Mac OS, Linux as well as Chrome, Firefox, Edge and many other major browsers.
  • Certified with the new FIDO2 standard, T110 provides the benefit of fast login and strong protection against phishing, account takeover as well as many other online attactks.
  • Works with : Bank of America, Github, Google, Microsoft, DUO, Twitter, Facebook, Dropbox, Apple, ebay, BINANCE, mor and more.
  • Fits USB-A port : Insert the T110 security key into the USB-A port of each service and log in conveniently with one touch
  • For the driver download and user guide, please visit TrustKey Solutions Home support page.
  1. Enable the Phone Number plugin in your Better Auth configuration.
  2. Run the migration or schema generation step described in the Phone Number documentation.
  3. If you manage your schema by hand, add the phoneNumber and phoneNumberVerified fields to the user table yourself, matching the plugin’s schema exactly.

Flows the plugin covers

  • Send and verify an OTP, the core flow that both callbacks serve.
  • Optional sign-up on verification, where a successful code can create the account.
  • Phone-number password sign-in, where a phone number and password authenticate the user.
  • Phone-number change after authentication, which verifies a new number for a signed-in user.
  • Password reset through a phone-number OTP.
  • Server-only consumePhoneNumberOTP, for custom sign-up or account-linking flows. It does not return a session or a reusable proof of verification, and the docs do not describe it as adding stronger concurrency guarantees. Do not treat its result as a token you can hand to the browser.

Check the version before you copy the page

The current Phone Number page and the v1.6 page both describe sendOTP, custom verifyOTP, and the same defaults. The current page adds detail on server-only consumption and concurrency. For a given project, the documentation matching your deployed Better Auth release is the authoritative source, so check which version your project installs before relying on any single page.

Choosing a delivery option

Better Auth’s documentation identifies a managed SMS service for OTP delivery, described on the v1.6 SMS service page. It also names Twilio Verify and AWS SNS as external integration examples. Choosing among them is a question of delivery, not verification. If you pick an external verifier, you also take on the job of confirming single-use behavior, as described above.

The Better Auth documentation does not compare providers on price, latency, deliverability, or reliability. Evaluate those points directly with each provider before committing.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.