How to implement passwordless login with phone number OTP in Better-Auth
Hi everyone, this is my first time of using better-auth
I’m trying to implement passwordless login using phone numbers and OTP in Better-Auth. I have: 1. Enabled the phoneNumber plugin. 2. Sent a request to
/phone-number/send-otp
/phone-number/send-otp
to get the OTP. 3. Verified the OTP via
/phone-number/verify
/phone-number/verify
.
The verification succeeds, but the response returns:
{ "code": "USER_NOT_FOUND", "message": "User not found"}
{ "code": "USER_NOT_FOUND", "message": "User not found"}
I suspect I’m missing a step. What is the correct flow for logging in users via phone number OTP? Do I need to create a user first, or is there a way to let Better-Auth handle it automatically?