useResendCode()
function useResendCode(): {
resendCode: () => void
resendCodeNode: undefined | UiNode
resendCodeStatus: OryResendCodeStatus
}
useResendCode provides a callback to trigger a code resend in the current flow.
You may use this hook to implement a "Resend Code" button in your forms.
If the current flow does not support code resending, resendCodeNode will be undefined and resendCode will be a no-op.
resendCodeStatus reports the last resend: "sending" while it is in flight, "sent" once Ory confirmed it, and "idle"
otherwise. It returns to "idle" when the resend fails, when the flow changes, or when the user tries to submit the form during
or after the resend, whether or not that submit succeeds. While the status is "sending", resendCode does nothing.
Example:
const { resendCode, resendCodeNode, resendCodeStatus } = useResendCode()
if (!resendCodeNode) {
return null
}
return (
<>
<span role="status">{resendCodeStatus === "sent" && "Code resent."}</span>
<button type="button" onClick={resendCode}>
Resend Code
</button>
</>
)
Returns
{
resendCode: () => void;
resendCodeNode: undefined | UiNode;
resendCodeStatus: OryResendCodeStatus;
}
the callback to trigger a code resend, the resend node, and the status of the last resend
| Name | Type | Default value |
|---|---|---|
resendCode() | () => void | handleResend |
resendCodeNode | undefined | UiNode | - |
resendCodeStatus | OryResendCodeStatus | - |