Skip to main content
General
Authentication

Overview

Learn more about authentication in the starter kit.

Open MarkdownFull AI corpusFeedback

Authentication is a core part of any SaaS application. The Pro Next.js Drizzle starter kit uses Better Auth to handle authentication and provides all the necessary UI for the authentication flow.

The starter kit comes with pre-configured providers, helper methods and extensions.

Included authentication flows

  • Email and password registration with email verification
  • Password reset and email-address changes
  • Passwordless passkey sign-in with biometric or device-PIN verification
  • Google OAuth and trusted account linking
  • Database-backed sessions with device revocation
  • TOTP two-factor authentication with failed-attempt lockout
  • Organization invitations and active-organization sessions
  • Administrator bans and impersonation

Two-factor authentication

Users with a credential account can enroll an authenticator app from Dashboard → Settings → Security. Enrollment requires the current password, then a valid six-digit TOTP code. After enrollment, password sign-in redirects to /auth/verify until the TOTP challenge succeeds.

Better Auth stores TOTP secrets and backup codes in the two_factor table. The current schema also tracks whether setup was verified, failed verification attempts and the lockout expiry. Apply committed database migrations when upgrading Better Auth so these security fields exist before deploying the new application code.

Passkeys

Users can register, rename and remove passkeys from Dashboard → Settings → Security, then choose Sign in with passkey on the authentication page. The included WebAuthn policy requires user verification through a biometric or device PIN before Better Auth creates a session.

A verified passkey completes the passwordless sign-in flow without an additional TOTP challenge. Password sign-in still follows the user's configured two-factor flow. Read the passkey guide for configuration, migrations, security boundaries and testing guidance.