two-factor-authentication-best-practices

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

Updated May 24, 2026
One-click install
npx skills add https://github.com/sAkuraOfficial/.agents --skill two-factor-authentication-best-practices-sakuraofficial
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: two-factor-authentication-best-practices
Source: https://github.com/sAkuraOfficial/.agents/tree/main/skills/two-factor-authentication-best-practices
Command: npx skills add https://github.com/sAkuraOfficial/.agents --skill two-factor-authentication-best-practices-sakuraofficial

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Configure TOTP authenticator apps, send OTP codes via email/SMS, manage backup codes, handle trusted devices, and implement 2FA sign-in flows using Better Auth's twoFactor plugin. Use when users need MFA, multi-factor authentication, authenticator setup, or login security with Better Auth.

Core Features & Use Cases

  • Configures TOTP-based authenticator setup with issuer and optional settings to customize digits and period.
  • Supports OTP delivery via email or SMS, with configurable period, digits, and retry policies.
  • Manages backup codes and trusted devices to streamline recovery and login experiences.
  • Provides a complete sign-in flow that enforces 2FA after credential verification and supports redirect to a dedicated 2FA page.
  • Includes server-side and client-side setup patterns to ensure seamless integration into existing apps.

Quick Start

Install and configure the twoFactor plugin with an issuer, wire up client-side twoFactorClient, and verify setup by enabling a test 2FA workflow.

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 implement two-factor authentication with TOTP and backup codes?

Implement two-factor authentication by configuring the twoFactor plugin to manage TOTP authenticator setup, generate secure backup codes, and enforce 2FA after credential verification. This provides a complete server-side and client-side sign-in flow.

How does 2FA state management work for trusted devices?

2FA state management for trusted devices works by storing secure secrets and backup codes on the server, while the client integration handles device trust to streamline recovery and login experiences without requiring repeated code entry.

Can I send OTP codes via email or SMS for multi-factor authentication?

Yes, you can send OTP codes via email or SMS for multi-factor authentication. The plugin supports configurable period, digits, and retry policies to customize OTP delivery according to your application requirements.

What's the best way to set up an authenticator app for 2FA sign-in flows?

The best way to set up an authenticator app for 2FA is configuring TOTP-based setup with a specified issuer and optional settings. You can customize digits and period, then wire up the client-side twoFactorClient to verify the workflow.

Does this 2FA workflow require server-side plugin configuration?

Yes, this 2FA workflow requires server-side plugin configuration to securely store secrets and backup codes. It also requires client-side setup patterns to ensure seamless integration into existing applications and manage 2FA state.

When do I need to redirect to a dedicated 2FA page during login?

You need to redirect to a dedicated 2FA page during login immediately after credential verification. This enforces the two-factor authentication step before granting access, ensuring robust login security across server and client configurations.