two-factor-authentication-best-practices

Configure Better Auth's twoFactor plugin for TOTP-based multi-factor authentication.

6|4|Updated Nov 1, 2025
One-click install
npx skills add https://github.com/Montte-erp/montte-nx --skill two-factor-authentication-best-practices-montte-erp
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: two-factor-authentication-best-practices
Source: https://github.com/Montte-erp/montte-nx/tree/main/.agents/skills/two-factor-authentication-best-practices
Command: npx skills add https://github.com/Montte-erp/montte-nx --skill two-factor-authentication-best-practices-montte-erp

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Implementing MFA is often manual and error-prone, leaving accounts vulnerable to credential theft. This Skill provides a structured approach to configuring and enforcing two-factor authentication using Better Auth's twoFactor plugin, including TOTP setup, OTP delivery, backup codes, trusted devices, and sign-in flows.

Core Features & Use Cases

  • TOTP-based authentication: Enforce time-based codes via authenticator apps (Google Authenticator, Authy, etc.).
  • OTP delivery (email/SMS): Send one-time codes for sign-in or recovery.
  • Backup codes & trusted devices: Provide secure access recovery and reduce friction by device trust.
  • End-to-end sign-in flow: Enrollment, verification, and session creation with 2FA enforcement, plus trusted-device handling.
  • Use Case: Onboard new employees who must set up MFA during first login.

Quick Start

Enable and configure the twoFactor plugin in your server and client to enforce TOTP-based authentication for 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 implement two-factor authentication using Better Auth?▼

Implementing two-factor authentication with Better Auth involves enabling and configuring the twoFactor plugin across both server and client to enforce TOTP-based authentication. This covers plugin installation, integration, and database migrations for secure login flows.

What is the best way to set up TOTP and backup codes for MFA enrollment?▼

The best way to set up TOTP and backup codes for MFA enrollment is using a structured plugin approach that generates time-based codes via authenticator apps while providing secure backup codes for access recovery and trusted devices to reduce login friction.

Can I use Better Auth's twoFactor plugin for OTP delivery via email and SMS?▼

Yes, you can use Better Auth's twoFactor plugin for OTP delivery via email and SMS. It supports sending one-time codes for both sign-in verification and account recovery within your web application's authentication lifecycle.

How does trusted-device management work with TOTP authentication?▼

Trusted-device management with TOTP authentication works by allowing users to mark specific devices as trusted after initial verification, reducing friction by bypassing repeated two-factor authentication prompts on known devices while maintaining login security.

What are the security considerations when enforcing multi-factor authentication?▼

Security considerations when enforcing multi-factor authentication include ensuring proper 2FA enforcement across all sign-in flows, secure backup code generation and storage, trusted-device validation, and correct server-client configuration to prevent credential theft vulnerabilities.