Skip to content

Two-Factor Challenge

The second factor with its fallback on the same screen, because a 2FA prompt with no recovery route is a lockout screen wearing a security screen.

2 blocks40 lineslucide-reactAdded 9 Sept 2026

What's included

  • app/two-factor-page.tsx
  • 2 blocks it is built from, installed with it
  • Needs lucide-react

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add two-factor-page

Or over MCP, from your editor's agent — no account needed.

License

Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.

Was this useful?

Preview

Two-factor authentication

Enter the 6-digit code from your authenticator app.

Lost your device

Check your email

We sent a 6-digit code to you@company.com

Did not get it?

0 of 6 digits entered

The real page, rendered in your current theme — every section below is a live block, not a screenshot.

Built from

All blocks
  1. Two-Factor ChallengeAuthenticator-code prompt with a backup-code escape hatch and an opt-in trusted-device checkbox that is off by default.
  2. One-Time Code InputSix-box OTP entry that handles paste, backspace, arrow keys and iOS SMS autofill — the parts hand-rolled versions always miss.

Only want one section? Open it and copy that block instead — browse Authentication.

Shipped in these templates

Want the whole project rather than this one screen? A template ships every route, the theme tokens and the layout.

Source

app/two-factor-page.tsx
/**
 * The second factor, and the fallback for when the second factor is gone.
 *
 * Two-factor screens ship as one input and a submit. That covers the happy
 * path and abandons the case that generates every support ticket: the
 * phone is lost, replaced, or in another room. A 2FA prompt with no
 * recovery route is a lockout screen wearing a security screen's clothes.
 *
 * So the authenticator challenge is first and the one-time-code fallback
 * is under it, on the same screen rather than behind a link. A recovery
 * path one click away is a recovery path somebody locked out will not find
 * while they are irritated.
 *
 * The obvious wrong answer is to lead with the fallback because it is
 * easier — that trains everybody onto the weaker factor, which is the
 * opposite of why this screen exists.
 */

import * as React from 'react'
import { AuthTwoFactor } from '@/components/auth-two-factor'
import { AuthOtpVerify } from '@/components/auth-otp-verify'

export default function TwoFactorPage() {
  return (
    <main className="min-h-screen bg-background text-foreground">
      <AuthTwoFactor />

      <div className="mx-auto flex w-full max-w-md items-center gap-4 px-6">
        <span className="h-px flex-1 bg-border" />
        <span className="text-xs font-medium uppercase tracking-wider text-muted-foreground">
          Lost your device
        </span>
        <span className="h-px flex-1 bg-border" />
      </div>

      <AuthOtpVerify />
    </main>
  )
}

How to use it

  1. 1. Copy each of the 2 blocks above into components/ — each block page has its own copy button.
  2. 2. Drop this file at app/two-factor-page.tsx. The imports already point at @/components/…, so they resolve with no edits.
  3. 3. Delete the sections you do not want. Every block takes props, so the copy changes without the layout moving.

For AI

The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.

See the prompt

More Auth Screens

Open the full page for this page

Signup Page

The signup form with the proof under it rather than above it — the person who arrived here has already decided, and scrolling past testimonials is friction applied to the wrong reader.

Auth Screens3 blocks34 lines
Open the full page for this page

Forgot Password

Password reset, plus the magic link beside it — the moment after a password has failed is when somebody is most willing to stop using one.

Auth Screens2 blocks46 lines
Open the full page for this page

SSO Sign In

A domain field for the employee who signs in daily, and the capability detail below the fold for the IT reviewer who reads it once.

Auth Screens2 blocks31 lines
Open the full page for this page

Reset Password

The end of the forgot-password flow, shipped with the state it reaches more than any other screen: a focused error summary linking to each field, beside a strength meter that is a real <meter>.

Auth Screens2 blocks36 lines