Menu

React Email Verification Needs Typed States
📰

React Email Verification Needs Typed States

DEV Community: typescript·ryanlee·3 days ago
#kpOiOgzV
#devtotypescript#devto#dev#email#state
Reading 0:00
15s threshold

Email verification looks like a small feature until a user clicks “send again” while a request is still running, opens an old link, or returns to the tab after the token expired. Then a simple isVerified boolean starts carrying too much meaning.

I have found a cleaner approach in React projects: model the verification journey as a small, typed state machine. It gives the UI a clear answer to “what can happen next?” and gives tests a stable contract. The result is less spinner guessing, fewer impossible screens, and a signup flow that feels intentional.

Why a boolean is too small for email verification

This is tempting:

const [ isVerified , setIsVerified ] = useState ( false ) ;

Enter fullscreen mode

Exit fullscreen mode

But false could mean all of these things:

The user has not submitted the form.

The verification request is in flight.

The email was sent successfully.

The request failed temporarily.

The link was invalid or already used.

The link expired.

Those states need different copy,…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.