Skip to content

useEmailAuth

Handles full email-based authentication flows: sign up, sign in, reset password, and link email.
Returns status, user data, and whether email verification is required.

Use cases:
  • Sign up or sign in users with email/password.
  • Link an email to an existing user.
  • Request or perform password resets.
Returns:
  • signInEmail, signUpEmail, linkEmail: Functions for authentication.
  • requestResetPassword, resetPassword: Password reset flows.
  • requiresEmailVerification: Whether user needs to verify their email.
  • Status flags: isLoading, isError, isSuccess, isAwaitingInput.
import { useEmailAuth } from "@openfort/react"
 
function SampleComponent() {
  const {
    signInEmail, // Sign in with email and password.
    signUpEmail, // Sign up with email and password.
    verifyEmail,
    linkEmail, // Link email to an existing account.
    requestResetPassword, // Request a password reset link to be sent to the user's email.
    resetPassword, // Reset the user's password using a reset link.
    reset, // Resets the state of the hook. (e.g. if isError resets to being without error)
    isLoading, // Indicates if the hook is currently loading.
    isError, // Indicates if the hook has encountered an error.
    isSuccess, // Indicates if the hook has successfully completed.
    error, // The error object if an error occurred, otherwise null.
    requiresEmailVerification,
    isAwaitingInput,
  } = useEmailAuth({
    emailVerificationRedirectTo, // The URL to redirect to after email verification.
    throwOnError, // Whether to throw errors.
    onSuccess, // Callback function to execute on success.
    onError, // Callback function to execute on error.
    onSettled, // Callback function to execute when the operation is settled (either success or error).
  })
  // ...
}