two-factor-authentication-best-practices

Configure Better Auth two-factor authentication with server and client integration.

1|Updated Mar 12, 2026
One-click install
npx skills add https://github.com/mahou-labs/shiru --skill two-factor-authentication-best-practices-mahou-labs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: two-factor-authentication-best-practices
Source: https://github.com/mahou-labs/shiru/tree/main/.agents/skills/two-factor-authentication-best-practices
Command: npx skills add https://github.com/mahou-labs/shiru --skill two-factor-authentication-best-practices-mahou-labs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

MFA adoption and secure login workflows can be error-prone and hard to standardize; this guide helps teams configure and manage two-factor authentication using Better Auth to reduce credential theft risk.

Core Features & Use Cases

  • Setup: integrate the twoFactor plugin on the server with an issuer and connect with a client-side twoFactorClient.
  • Enabling/Managing 2FA: enable 2FA for users, generate TOTP QR codes, deliver OTP via email/SMS, and manage backup codes and trusted devices.
  • Security & Compliance: include rate limiting, encryption at rest for secrets, and configurable session behavior to protect user accounts.

Quick Start

Configure the twoFactor plugin on the server with an issuer, connect the client with twoFactorClient, and run the migration to enable 2FA for your users.

Frequently Asked Questions about two-factor-authentication-best-practices

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

FAQPage Schema
How do I set up two-factor authentication using Better Auth?

To set up two-factor authentication, configure the twoFactor plugin on your server with an issuer, connect the client using twoFactorClient, and run database migrations to activate MFA across user sign-in flows.

Can I deliver 2FA OTP codes via email or SMS with Better Auth?

Yes, the two-factor authentication workflow supports delivering OTP codes to users via either email or SMS, alongside generating TOTP QR codes for authenticator apps.

How do backup codes work in two-factor authentication workflows?

Backup codes are generated and managed within the 2FA workflow to provide users with reliable account access when their primary OTP delivery method or trusted device is unavailable.

Does two-factor authentication require encryption at rest for TOTP secrets?

Yes, the two-factor authentication setup includes encryption at rest for secrets and configurable rate limiting to protect user accounts against credential theft and brute-force attacks.

What is the best way to enforce MFA across web app sign-in flows?

The best way to enforce MFA is by integrating the twoFactor plugin server-side with configurable session behavior, ensuring all web app users complete the 2FA challenge during sign-in.