Setup the phoneHarmony plugin
mainThe phoneHarmony plugin intercepts and modifies the user's phoneNumber, ensuring only normalized numbers are stored in the backend.
Note: Unlike emailHarmony, this plugin modifies the phoneNumber field directly.
Installation
npm i better-auth-harmonyConfiguration
To use phoneHarmony, you must also include the base phoneNumber() plugin from better-auth/plugins:
import { betterAuth } from 'better-auth';
import { phoneNumber } from 'better-auth/plugins';
import { phoneHarmony } from 'better-auth-harmony';
export const auth = betterAuth({
// ... other config options
plugins: [phoneNumber(), phoneHarmony()]
});For details on configuring phoneNumber() validation, refer to the official better-auth documentation.