@leancodepl/kratos
Version:
Headless React components library for building Ory Kratos authentication flows
61 lines (60 loc) • 2.94 kB
TypeScript
import { ComponentType } from "react";
import { EmailVerificationFormProps } from "../verification";
import { ChooseMethodFormProps } from "./chooseMethodForm";
import { SecondFactorEmailFormProps } from "./secondFactorEmailForm";
import { SecondFactorFormProps } from "./secondFactorForm";
import { OnLoginFlowError } from "./types";
export type LoginFlowProps = {
loaderComponent?: ComponentType;
chooseMethodForm: ComponentType<ChooseMethodFormProps>;
secondFactorForm: ComponentType<SecondFactorFormProps>;
secondFactorEmailForm: ComponentType<SecondFactorEmailFormProps>;
emailVerificationForm: ComponentType<EmailVerificationFormProps>;
initialFlowId?: string;
returnTo?: string;
onError?: OnLoginFlowError;
onLoginSuccess?: () => void;
onVerificationSuccess?: () => void;
onFlowRestart?: () => void;
onSessionAlreadyAvailable?: () => void;
};
/**
* Renders a complete login flow with multi-step authentication support.
*
* Handles login method selection, second-factor authentication, email verification,
* and session management. Provides context for managing flow state and transitions
* between different authentication steps.
*
* @param props - Configuration and component props for the login flow
* @param props.loaderComponent - Optional component to display during loading states
* @param props.chooseMethodForm - React component for login method selection
* @param props.secondFactorForm - React component for second factor authentication
* @param props.secondFactorEmailForm - React component for email-based second factor
* @param props.emailVerificationForm - React component for email verification process
* @param props.initialFlowId - Optional existing login flow ID to resume
* @param props.returnTo - Optional URL to redirect after successful login
* @param props.onError - Optional callback for handling login flow errors
* @param props.onLoginSuccess - Optional callback triggered after successful login
* @param props.onVerificationSuccess - Optional callback triggered after email verification
* @param props.onFlowRestart - Optional callback triggered when flow restarts due to expiration
* @param props.onSessionAlreadyAvailable - Optional callback triggered when user is already authenticated
* @returns JSX element containing the complete login flow interface
* @example
* ```tsx
* import { LoginFlow } from '@leancodepl/kratos';
*
* function App() {
* return (
* <LoginFlow
* chooseMethodForm={ChooseMethodForm}
* secondFactorForm={SecondFactorForm}
* secondFactorEmailForm={SecondFactorEmailForm}
* emailVerificationForm={EmailVerificationForm}
* onLoginSuccess={() => navigate('/dashboard')}
* onSessionAlreadyAvailable={() => navigate('/dashboard')}
* />
* );
* }
* ```
*/
export declare function LoginFlow(props: LoginFlowProps): import("react/jsx-runtime").JSX.Element;