React Email Verification: Make Pending a Real State
Email verification often starts as a tiny React feature: show a form, call an endpoint, then display “verified.” The rough edges arrive between those moments: delayed messages, expired codes, resend races, and refreshes at the wrong time.
The fix is to stop treating verification as a boolean. In a TypeScript UI, model the journey as a small state machine with explicit pending, expired, and failure states. It makes the screen easier to understand and the API contract easier to test. A free temporary email inbox or a test fixture is useful during development, but it should not hide lifecycle bugs.
The UI problem: verification is not a boolean
isVerified: boolean cannot explain what the user should do next. false might mean that the request has not started, the email is on its way, the code was rejected, or the verification link expired.…