Configuration
Everything is configured under betterAuthUi in nuxt.config.ts. The sign-in pages, the account page and the admin
dashboard are on from the start; every other feature is off until you turn it on.
export default defineNuxtConfig({
modules: ['@treygrr/nuxt-better-auth-ui'],
betterAuthUi: {
twoFactor: { enabled: true },
magicLink: { enabled: true },
emails: { send: './server/emails/send.ts' }
}
})
How a feature is added
Most features are one of Better Auth's own plugins. When you turn one on, the module:
- adds the plugin to Better Auth's server and client config for you, so your
server/auth.config.tsandapp/auth.config.tsdon't change; - shows it on the pages that use it: a button on the sign-in page, a card on the account page, a column in the admin;
- lists it on the admin's configuration page, so staff can see how the app is set up.
Adding a plugin yourself
The pages read your Better Auth set-up at runtime, so they also pick up plugins your own auth config adds. That's useful when you need a plugin option the module doesn't pass through: leave the module's option off, add the plugin and its client plugin to your auth configs, and the pages show it all the same. A few extras only come with the module's own plugin; their pages say which.
Features
| Feature | Option | Package to install | Migration |
|---|---|---|---|
| Two-factor authentication | twoFactor | Yes | |
| Passkeys | passkey | @better-auth/passkey | Yes |
| Usernames | username | Yes | |
| Sign-in links | magicLink | No | |
| Codes by email | emailOtp | No | |
| Guest accounts | anonymous | Yes | |
| Several accounts | multiSession | No | |
| Phone numbers | phoneNumber, sms | Yes | |
| Signing in devices | deviceAuthorization | Yes | |
| Provider sign-in in a popup | oauthPopup | No | |
| Captcha | captcha | No | |
| Breached passwords | haveIBeenPwned | No | |
| "Last used" method | lastLoginMethod | No | |
| Security alerts | securityAlerts | No | |
| Organizations | organization | Yes | |
| Single sign-on | sso | @better-auth/sso | Yes |
| Subscriptions with Stripe | stripe | @better-auth/stripe, stripe | Yes |
| API keys | apiKey | @better-auth/api-key | Yes |
| Bearer tokens | bearer | No | |
| JWTs | jwt | Yes | |
| Emails | emails | No |
General options
false to leave one out. See Sign-in pages.Environment variables
Secrets are read from the environment at runtime, never from nuxt.config.ts:
Better Auth's own variables (its secret and base URL) work as usual; see
@nuxtjs/better-auth.