@leancodepl/kratos
Version:
Headless React components library for building Ory Kratos authentication flows
50 lines (49 loc) • 2.08 kB
TypeScript
import { ComponentType } from "react";
import { NewPasswordFormProps } from "../settings";
import { CodeFormProps } from "./codeForm";
import { EmailFormProps } from "./emailForm";
import { OnRecoveryFlowError } from "./types";
export type RecoveryFlowProps = {
emailForm: ComponentType<EmailFormProps>;
codeForm: ComponentType<CodeFormProps>;
newPasswordForm: ComponentType<NewPasswordFormProps>;
initialFlowId?: string;
returnTo?: string;
onError?: OnRecoveryFlowError;
onRecoverySuccess?: () => void;
onFlowRestart?: () => void;
};
/**
* Renders a multi-step password recovery flow with email verification and password reset.
*
* Manages the complete recovery process from email submission through code verification
* to password reset, automatically handling flow state transitions and provider setup.
*
* @param props.emailForm - React component for email input step
* @param props.codeForm - React component for verification code input step
* @param props.newPasswordForm - React component for new password input step
* @param props.initialFlowId - Optional existing recovery flow ID to continue
* @param props.returnTo - Optional URL to redirect after successful recovery
* @param props.onError - Optional error handler for recovery flow failures
* @param props.onRecoverySuccess - Optional callback fired when password recovery completes
* @param props.onFlowRestart - Optional callback fired when flow restarts due to errors
* @returns JSX element with configured recovery flow providers and step management
*
* @example
* ```tsx
* import { RecoveryFlow } from "@leancodepl/kratos";
*
* function App() {
* return (
* <RecoveryFlow
* emailForm={EmailForm}
* codeForm={CodeForm}
* newPasswordForm={NewPasswordForm}
* onRecoverySuccess={() => console.log("Recovery completed")}
* onError={(error) => console.error("Recovery failed:", error)}
* />
* );
* }
* ```
*/
export declare function RecoveryFlow(props: RecoveryFlowProps): import("react/jsx-runtime").JSX.Element;