two-factor-authentication-best-practices

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

1|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/dotlab-hq/storage-platform --skill two-factor-authentication-best-practices-dotlab-hq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: two-factor-authentication-best-practices
Source: https://github.com/dotlab-hq/storage-platform/tree/main/.agents/skills/two-factor-authentication-best-practices
Command: npx skills add https://github.com/dotlab-hq/storage-platform --skill two-factor-authentication-best-practices-dotlab-hq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps teams securely implement multi-factor authentication using Better Auth, guiding setup and maintenance to protect user sign-ins.

Core Features & Use Cases

  • Comprehensive MFA: Supports TOTP authenticator apps, OTP emails, and backup codes to enforce MFA across sign-ins.
  • Seamless Setup & Recovery: Provides server and client plugin configuration, migration steps, and verification flows to enable and recover 2FA smoothly.
  • Use Case: Enterprises needing stronger login security can enable 2FA for all users and enforce trusted devices with configurable lifetimes.

Quick Start

Enable two-factor authentication by wiring the twoFactor and twoFactorClient plugins and performing the migration.

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 configure two-factor authentication with Better Auth?

Configure two-factor authentication by wiring the twoFactor server plugin and twoFactorClient into your application, then run database migrations to generate required tables for secure sign-ins.

What methods are supported for MFA delivery in Better Auth?

Better Auth supports multiple MFA delivery methods, including TOTP authenticator apps, OTP emails, and backup codes to verify user sign-ins across various devices.

How does QR provisioning work for TOTP authenticator apps?

QR provisioning generates a scannable code to link authenticator apps, allowing users to verify 2FA by displaying the QR code and submitting the generated time-based password.

Can I enforce trusted devices and manage backup codes for 2FA recovery?

Yes, you can enforce trusted devices with configurable lifetimes and generate backup codes, enabling users to recover access smoothly if they lose their primary 2FA method.

Does implementing two-factor authentication require manual database migrations?

Yes, implementing two-factor authentication requires running database migrations after wiring the twoFactor plugin to create the necessary schema for storing OTP and device verification data.

What is the best way to handle 2FA verification flows on the client side?

The best way to handle 2FA verification flows is using the twoFactorClient plugin to manage QR code display, prompt for OTP input, and verify codes against the server.