email-and-password-best-practices

Configures secure email and password authentication flows using Better Auth.

4|Updated Oct 24, 2025
One-click install
npx skills add https://github.com/sethdavis512/iridium --skill email-and-password-best-practices-sethdavis512
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: email-and-password-best-practices
Source: https://github.com/sethdavis512/iridium/tree/main/.agents/skills/email-and-password-best-practices
Command: npx skills add https://github.com/sethdavis512/iridium --skill email-and-password-best-practices-sethdavis512

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Implementing email and password authentication involves many security-sensitive decisions—email verification, password reset flows, token handling, and hashing algorithms—where mistakes lead to account takeover, timing attacks, or open redirect vulnerabilities. This Skill provides concrete Better Auth configuration patterns that enforce security best practices. ## Core Features & Use Cases - Email Verification Setup: Configure sendVerificationEmail and optionally require verification before sign-in to block fake accounts. - Secure Password Reset Flows: Implement reset emails with timing-attack prevention, single-use expiring tokens, session revocation, and redirect URL validation against trusted origins. - Password Hashing Guidance: Use the default scrypt hashing or plug in Argon2id via custom hash and verify functions with recommended parameters. - Use Case: When adding email/password sign-in to a Better Auth application, apply these patterns to ensure reset tokens expire, sessions are revoked on password change, and callback URLs use absolute origins. ## Quick Start Apply the email and password best practices to configure Better Auth with email verification and a secure password reset flow in my project.

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 set up email verification with Better Auth?▼

Configure `emailVerification.sendVerificationEmail` in the Better Auth options with a function that sends the verification URL to the user's email. To block unverified sign-ins, also enable `emailAndPassword.requireEmailVerification`, which resends a verification email on each sign-in attempt.

How do I implement a password reset flow in Better Auth?▼

Provide a `sendResetPassword` function in the `emailAndPassword` config that emails the reset URL, then call `requestPasswordReset` from the client or API with the user's email and a `redirectTo` URL. Better Auth handles token generation, expiration, and single-use deletion automatically.

Does Better Auth protect password reset against timing attacks?▼

Yes. Better Auth sends reset emails in the background, performs dummy token generation and database lookups for nonexistent users, and always returns the same response message. On serverless platforms, configure `advanced.backgroundTasks.handler` with `waitUntil` to ensure emails send reliably.

Can I use Argon2id instead of scrypt for password hashing in Better Auth?▼

Yes. Provide custom `hash` and `verify` functions under `emailAndPassword.password`, for example using `@node-rs/argon2` with Argon2id parameters. Note that existing users hashed with the old algorithm cannot sign in, so plan a migration strategy.

Why should callback URLs be absolute in Better Auth?▼

Absolute callback URLs including the origin prevent Better Auth from inferring the origin, which fails when frontend and backend run on different domains. The `redirectTo` parameter is also validated against `trustedOrigins` to block open redirect attacks.