Logout Button
LogoutButton is a ready-made sign-out action for account settings. It calls
logout() on the active OvokClient, signs out of Google when needed, and
notifies mounted auth hooks to refresh. Your app owns navigation and any
unsaved-work confirmation.
Add the button
import { LogoutButton } from "@ovok/native";
import { Alert } from "react-native";
export function AccountActions() {
return (
<LogoutButton
variant="button"
title="Sign out"
onError={() =>
Alert.alert("Couldn't sign out", "Check your connection and try again.")
}
/>
);
}
Render the button below OvokProvider. The default
variant is "row", which renders a settings-list row. Use variant="button"
for a full-width React Native Paper button. The button variant accepts a
custom Button component; both variants accept inherited settings-row props
such as disabled, style, and testID.
Handle request outcomes
onPress runs when the user presses the action and before the logout request.
onError receives a request error. There is a callback behavior to account for
in the current implementation: onSuccess runs in the finally path, so it
also runs after onError. Do not use it as proof that the server accepted the
logout. For success-dependent navigation, track the request outcome in
app-owned code or use an auth-state gate.
The control prevents duplicate logout requests while busy. Use its loading
and disabled props to coordinate it with the rest of the settings screen.
Related guides
- Session management for custom session controls
- Delete account for account deletion