Module - Better-Auth
The easiest way to get it today is to create a remult project with the cli and select better-auth
as the auth provider. remult - Creating a project
npm init remult@latest
Then, you can take the ./src/demo/auth
folder and copy it to your own project.
I suggest to put it in a ./src/modules
folder.
Playing well with mail module
Section titled “Playing well with mail module”When you use the mail
module, you can use the sendVerificationEmail
function to send a
verification email.
export const auth = betterAuth({ database: remultAdapter(remult, { authEntities, usePlural: true, }),
emailAndPassword: { enabled: true, requireEmailVerification: true, },
emailVerification: { autoSignInAfterVerification: true, async sendVerificationEmail(data) { const { user, url } = data remult.context.sendMail?.('sendVerificationEmail', { to: user.email, subject: 'Welcome to our app!', sections: [{ html: 'Verify your email', cta: { html: 'Verify', link: url } }], }) }, },})