email-and-password-best-practices

Configure Better Auth email verification and password reset flows.

885|108|Updated Apr 30, 2025
One-click install
npx skills add https://github.com/legions-developer/invoicely --skill email-and-password-best-practices-legions-developer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: email-and-password-best-practices
Source: https://github.com/legions-developer/invoicely/tree/main/.agents/skills/emailAndPassword
Command: npx skills add https://github.com/legions-developer/invoicely --skill email-and-password-best-practices-legions-developer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the security and reliability problems that come from incomplete or inconsistent email/password authentication flows, including missing verification, weak password policies, and unsafe reset handling.

Core Features & Use Cases

  • Email Verification Setup: Configure emailVerification.sendVerificationEmail to send a verification link and optionally require verified emails before sign-in.
  • Password Reset Flows: Implement sendResetPassword and support secure reset requests with token expiration, optional session revocation, and an event hook.
  • Password Hashing & Policies: Set password length requirements and override the default password hashing (e.g., Argon2id) with custom hash and verify functions while planning safe migrations.

Example use case: enable verification and password resets for a SaaS app so users must confirm their email before accessing protected features, while lost-password requests reliably send reset links that expire and can revoke existing sessions.

Quick Start

Configure Better Auth to enable emailAndPassword, provide emailVerification.sendVerificationEmail and sendResetPassword, and run npx @better-auth/cli@latest migrate to apply the authentication changes.

Frequently Asked Questions about email-and-password-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure email verification in Better Auth to require confirmation before login?

Email verification in Better Auth is configured by enabling the emailAndPassword plugin and wiring the emailVerification.sendVerificationEmail function. You can optionally enforce requireEmailVerification to block sign-in until the user confirms their email link.

How do I implement a secure password reset flow with token expiration in Better Auth?

Implement secure password reset handling in Better Auth by configuring the sendResetPassword function. This setup ensures reset requests use tokens with expiry limits, can revoke existing sessions, and trigger event hooks for reliable credential recovery.

Can I override the default password hashing algorithm in Better Auth with Argon2id?

Yes, you can override the default password hashing in Better Auth by providing custom hash and verify functions. This allows you to implement stronger algorithms like Argon2id and enforce specific password length requirements while planning safe migrations.

How does Better Auth handle session revocation during a password reset?

Better Auth supports session revocation during password reset by utilizing event hooks within the sendResetPassword flow. This mechanism ensures that existing user sessions are securely invalidated when a lost-password request successfully processes.

Do I need to run database migrations when adding email and password authentication to Better Auth?

Yes, you must run database migrations after enabling emailAndPassword and configuring email verification or reset policies. Execute npx @better-auth/cli@latest migrate to apply the required authentication schema changes to your database.

What is the best way to secure email and password authentication flows in a SaaS application?

Securing email and password authentication involves enforcing email verification before access, configuring password resets with token expiration, and overriding default hashing with Argon2id to ensure user identity assurance and safe credential recovery.