@leancodepl/kratos
Version:
Headless React components library for building Ory Kratos authentication flows
33 lines (32 loc) • 951 B
TypeScript
import { ApiResponse } from "../../types";
/**
* Provides logout functionality for Kratos authentication flows.
*
* Handles the complete logout process including creating logout flow,
* updating session state, cleaning up cached queries, and optional redirects.
*
* @returns Object containing logout function that accepts optional returnTo parameter
* @example
* ```tsx
* import { useLogout } from "@leancodepl/kratos";
*
* function LogoutButton() {
* const { logout } = useLogout();
*
* const handleLogout = async () => {
* const result = await logout({ returnTo: "/login" });
* if (!result.isSuccess) {
* console.error("Logout failed:", result.error);
* }
* };
*
* return <button onClick={handleLogout}>Logout</button>;
* }
* ```
*/
export type UseLogout = () => {
logout: ({ returnTo }: {
returnTo?: string;
}) => Promise<ApiResponse>;
};
export declare const useLogout: UseLogout;