Better Auth Harmony is a plugin for the `better-auth` framework, designed to enhance user input handling by providing robust validation and normalization functionalities. It specifically targets email addresses, detecting and blocking disposable domains, as well as standardizing phone numbers. The library aims to improve data quality and security within applications leveraging `better-auth` for user authentication. The current stable version is `1.3.2`, with a release cadence that includes regular patch and minor updates to address bugs and introduce new features. Its primary differentiator lies in its deep integration with the `better-auth` ecosystem, offering specialized validation and normalization that aligns with `better-auth`'s architecture, thereby providing a comprehensive solution for managing user identity data.
npm install better-auth-harmonyVerified import paths — ran on the pinned version, not inferred.
This code demonstrates how to integrate `emailHarmony` and `phoneHarmony` plugins into a `better-auth` instance. It showcases the plugin-based configuration and highlights automatic normalization and validation features.
Review the `better-auth` changelog for API changes in version 1.5.0 and ensure your `better-auth-harmony` configuration and usage align with the updated `better-auth` API. Consult the `better-auth-harmony` documentation for any specific migration steps related to API paths.
Upgrade to `better-auth-harmony@1.3.2` or later to resolve the normalized email login issue.
Upgrade to `better-auth-harmony@1.3.1` or later. If issues persist in complex ESM setups, consider workarounds mentioned in the `better-auth-harmony` documentation such as using Node.js 22+, `NODE_OPTIONS=--experimental-detect-module` for Node >= 20.10, or patching `validator.js` to include `"type": "module"` in its `package.json`.
Upgrade to `better-auth-harmony@1.3.1` or newer. If using Next.js, add `better-auth-harmony` to `transpilePackages` in `next.config.js`. For Vite, add it to `ssr.noExternal` in `vite.config.js`. Alternatively, ensure Node.js 22+ is used, or pass `NODE_OPTIONS=--experimental-detect-module` for Node >= 20.10.
Ensure you are using `import { emailHarmony } from 'better-auth-harmony';` for ESM environments. Verify your `package.json` `type` field and module resolution settings if using a mixed environment.To allow users to sign in with either their normalized or unnormalized email, configure `emailHarmony` with `allowNormalizedSignin: true`. This will perform an additional database lookup for the normalized version of the email.