useSignOut
Sign out users and invalidate their current session and stored authentication state.
Request
type Request = {
hook: 'useSignOut',
params: [options?: OpenfortHookOptions]
}
type OpenfortHookOptions = {
onSuccess?: (data?: { error?: import("@openfort/react-native").OpenfortError }) => void
onError?: (error: import("@openfort/react-native").OpenfortError) => void
onSettled?: (data?: { error?: import("@openfort/react-native").OpenfortError } | undefined | null, error: import("@openfort/react-native").OpenfortError | null) => void
throwOnError?: boolean
}
Response
type Response = SignOutReturn
type SignOutReturn = SignOutStatusFlags & {
signOut(options?: OpenfortHookOptions): Promise<void | { error: import("@openfort/react-native").OpenfortError }>
}
type SignOutStatusFlags = {
isLoading: boolean
isError: boolean
isSuccess: boolean
error?: import("@openfort/react-native").OpenfortError | null
}
Example
import { useSignOut } from "@openfort/react-native"
function LogoutButton() {
const { signOut, isLoading, isError, isSuccess, error } = useSignOut({
throwOnError: true,
onSuccess: () => {},
onError: () => {},
onSettled: () => {},
})
return <Button title="Sign out" onPress={() => signOut()} disabled={isLoading} />
}