two-factor-authentication-best-practices

Implement two-factor authentication for Better Auth with TOTP, OTP, and backup codes.

3|2|Updated Mar 25, 2026
One-click install
npx skills add https://github.com/zaid-khan-code/learnHub-ai-powered-online-learning-platform-lms --skill two-factor-authentication-best-practices-zaid-khan-code
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: two-factor-authentication-best-practices
Source: https://github.com/zaid-khan-code/learnHub-ai-powered-online-learning-platform-lms/tree/main/.agents/skills/two-factor-authentication-best-practices
Command: npx skills add https://github.com/zaid-khan-code/learnHub-ai-powered-online-learning-platform-lms --skill two-factor-authentication-best-practices-zaid-khan-code

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you add reliable multi-factor authentication to Better Auth applications, reducing account takeover risk and giving users safer sign-in and recovery options.

Core Features & Use Cases

  • Authenticator App Support: Configure TOTP with QR-code setup and code verification for app-based second factors.
  • Email and SMS OTP: Send one-time passwords through custom delivery logic for users who cannot use authenticator apps.
  • Recovery and Trust Controls: Manage backup codes, trusted devices, temporary 2FA sessions, and disable flows with password confirmation.
  • Use Case: Use this Skill when building a production login experience that needs strong authentication, flexible recovery paths, and secure enrollment workflows.

Quick Start

Set up Better Auth two-factor authentication by adding the plugin, configuring the client redirect flow, and enabling the verification methods you want for your login system.

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 with Better Auth?

Set up two-factor authentication by adding the Better Auth twoFactor plugin, running database migrations for twoFactorSecret, and configuring client redirect flows and verification methods.

Does Better Auth support TOTP authenticator apps and email OTP delivery?

Better Auth supports both TOTP authenticator apps with QR-code setup and email or SMS OTP delivery through custom delivery logic for flexible second-factor verification.

How do backup codes and trusted devices work in Better Auth 2FA flows?

Backup codes and trusted devices in Better Auth 2FA flows provide recovery paths and persistent trust, managed alongside temporary 2FA sessions and disable flows requiring password confirmation.

What database changes are needed to enable two-factor verification in Better Auth?

Enabling two-factor verification requires database migration support to add the twoFactorSecret field, alongside configurable rate limiting, encryption, and session handling for secure authentication.

What is the best way to handle 2FA recovery and disable flows in a production login experience?

Handle 2FA recovery and disable flows by implementing backup code generation, managing trusted devices, and requiring password confirmation before disabling two-factor authentication.

Can I configure rate limiting and session handling for Better Auth two-factor plugins?

Better Auth two-factor plugins support configurable rate limiting and session handling, allowing you to secure authentication flows and manage temporary 2FA sessions effectively.