import { createFileRoute, Link } from '@tanstack/react-router' import { useState } from 'react' import { Button } from '~/components/ui/button' import { Spinner } from '~/components/ui/spinner' import { AuthCard } from '~/features/auth/auth-card' import { FormAlert } from '~/features/auth/form-alert' import { authClient } from '~/server/better-auth/client' interface VerifyEmailSearch { email?: string } export const Route = createFileRoute('/auth/verify-email')({ validateSearch: (search: Record): VerifyEmailSearch => ({ email: typeof search.email === 'string' ? search.email : undefined, }), component: VerifyEmail, }) function VerifyEmail() { const { email } = Route.useSearch() const [status, setStatus] = useState<'idle' | 'sending' | 'sent' | 'error'>('idle') const resend = async () => { if (!email) return setStatus('sending') const { error } = await authClient.sendVerificationEmail({ email, callbackURL: '/' }) setStatus(error ? 'error' : 'sent') } return ( A confirmation link was sent{email ? ` to ${email}` : ''}. Click it to activate your account. } footer={ Back to sign in } title="Confirm your email" >
{status === 'sent' ? ( Request sent. If your address isn't confirmed yet, you'll get an email — check your spam folder. ) : null} {status === 'error' ? Could not send. Try again shortly. : null}

Didn't get anything? Check your spam folder or resend the link.

) }