Skip to main content

Overview

useSendVerificationEmail returns a function that sends a verification email to the currently authenticated user. The token expires after 5 minutes. Calling it on an already-verified user is a no-op (returns { success: true } without sending).

Usage Example

import { useSendVerificationEmail } from "@replyke/react-js";

function VerifyEmailPrompt() {
  const sendVerificationEmail = useSendVerificationEmail();

  return (
    <button
      onClick={() =>
        sendVerificationEmail({ tokenFormat: "numeric", tokenLength: 6 })
      }
    >
      Send verification code
    </button>
  );
}

Parameters

The returned function accepts an optional props object:
mode
"code" | "link"
default:"\"code\""
How the token is delivered.
  • "code" — user receives a token to type into your app
  • "link" — user receives a clickable button that verifies automatically
tokenFormat
"hex" | "numeric" | "alpha" | "alphanumeric"
default:"\"hex\""
Character set for the token. "numeric" is recommended for OTP-style flows; "hex" for maximum entropy.
tokenLength
number
default:"6"
Length of the generated token (4–12). Ignored when tokenFormat is "hex".
redirectUrl
string
URL to redirect to after link verification. Only used with mode: "link". Receives ?verified=true or ?verified=false&error=... as query params.

Returns

The hook returns an async function. That function resolves to:
success
boolean
true when the request completes without a server error.

See Also