Skip to main content
The useLogout hook logs out the current user and clears their session. Optionally clears any pregenerated wallets stored for the user.

Import

import { useLogout } from "@getpara/react-native-wallet";

Usage

import { useLogout } from "@getpara/react-native-wallet";
import { Alert, Button } from "react-native";

function LogoutButton() {
  const { logoutAsync, isPending } = useLogout();

  const handleLogout = () => {
    Alert.alert("Sign Out", "Are you sure you want to sign out?", [
      { text: "Cancel", style: "cancel" },
      {
        text: "Sign Out",
        style: "destructive",
        onPress: async () => {
          try {
            await logoutAsync({});
          } catch (err) {
            console.error(err);
          }
        },
      },
    ]);
  };

  return <Button title={isPending ? "Signing out..." : "Sign Out"} onPress={handleLogout} disabled={isPending} />;
}