how can i setup better-auth without an email?

title
6 Replies
sacrosanctic
sacrosancticOP2w ago
@Better Auth how to setup without email
Better Auth
Better Auth2w ago
By design, Better Auth requires an email address on every user record—even if you're using external providers or alternative flows—because the email field is used for notifications, password resets, and uniqueness [8]. That said, if you’d like to avoid having users input an email manually, you have a couple of options: 1. Use a social provider that doesn’t supply an email (or uses a fallback value). For example, the Roblox provider maps the preferred_username to the email field when an actual email isn’t available [6].
2. Consider using the anonymous plugin. This lets users authenticate without providing an email up front. They can later link an authentication method (which may include email) when they’re ready [12]. So while you can build flows that don’t require the user to enter an email during sign-up, Better Auth still relies on having an email value for each account internally. Sources: [6] Roblox | Better Auth [8] Email | Better Auth [12] Anonymous | Better Auth — Better Auth is powered by https://clarm.com
Roblox | Better Auth
Roblox provider setup and usage.
Email | Better Auth
Learn how to use email with Better Auth.
sacrosanctic
sacrosancticOP2w ago
@Better Auth once they sign in as anon, how to signin with line oauth without email
Better Auth
Better Auth2w ago
When an anonymous user later signs in with LINE OAuth, you can take advantage of Better Auth’s account‐linking functionality to merge the temporary anonymous account with the new LINE OAuth credentials—even if LINE doesn’t immediately provide an email address. Here’s how to do it: 1. In your anonymous plugin configuration (see Document 1), you can specify an emailDomainName (for example, "OCId-User") so that any anonymously created account uses a fallback dummy email. This dummy email acts as a placeholder until a proper email is obtained or until you decide to update it. 2. When the user initiates the LINE OAuth flow (available via the LINE provider you’ve configured as in Document 15), you should call the LINE OAuth sign-in method while the anonymous session is still active. Better Auth will detect that the user is signed in anonymously and will trigger the onLinkAccount callback provided in your anonymous plugin configuration (Document 23). This callback lets you merge the new OAuth credentials with the existing anonymous account. 3. In your onLinkAccount callback, you can customize how the account linking is handled. For example, you might choose to update or keep the dummy email, or prompt the user to supply a real email later if needed. This configuration ensures that even if LINE does not return an email, the anonymous account continues to work and can be seamlessly linked to the LINE OAuth credentials using Better Auth’s built‐in linking functionality [1][23]. Sources: [1] Auto signin not working on Anonumous [23] Anonymous | Better Auth — Better Auth is powered by https://clarm.com
GitHub
Auto signin not working on Anonumous · Issue #3267 · better-auth/...
Is this suited for github? Yes, this is suited for github To Reproduce setup a next js integration be following the docs https://www.better-auth.com/docs/integrations/next set up the anonymous plug...
Anonymous | Better Auth
Anonymous plugin for Better Auth.
Clarm
Automate customer support with AI for developer, finance, and technical teams
sacrosanctic
sacrosancticOP2w ago
@Better Auth i get this error before onlinkaccount is called Provider did not return email. This could be due to misconfiguration in the provider settings.
Better Auth
Better Auth2w ago
Hi there! The error indicates that Better Auth didn't receive an email from your provider, which is required during the linking flow. This can happen if the provider isn’t configured to return the email address or if its permissions/scopes aren’t set up properly. To fix this, please verify the following: 1. Ensure that your provider’s settings (or dashboard) are configured to include the email scope so that an email address is returned during authentication. 2. If you’re using a provider that traditionally doesn’t return an email (for example, Twitter/X), make sure you’ve enabled the appropriate account linking options (such as enabling the option to allow linking accounts even with different or missing emails) in your Better Auth configuration [1]. 3. Also, double-check that your onLinkAccount callback is correctly set up, as it only runs after account linking succeeds. So, addressing the email issue beforehand should help trigger your callback as expected [5]. Hope that helps! Let me know if you have any more questions. Sources: [1] User & Accounts | Better Auth [5] account linking still requires email — Better Auth is powered by https://clarm.com
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
User & Accounts | Better Auth
User and account management.
GitHub
account linking still requires email · Issue #2172 · better-auth/...
Is this suited for github? Yes, this is suited for github To Reproduce Create a config for a generic provider that does not provide the user email (similar to Twitter/X). The email_is_missing error...
Clarm
Automate customer support with AI for developer, finance, and technical teams

Did you find this page helpful?