Disconnect Safe Wallet
Disconnects connected Safe Wallet through AppKit. Also redirects at relative path, if attached. Otherwise, use should mofidy page based on state
.
import { useDisconnect } from '@reown/appkit/react'
type DisconnectProps = { redirectPath: string | null;};
export const Disconnect_btn = ({redirectPath} : DisconnectProps) => {
const { disconnect } = useDisconnect();
const handleDisconnect = async (redirectPath: string | null) => {
try {
await disconnect();
if(redirectPath) return window.location.href = redirectPath;
} catch (error) {
console.error("Failed to disconnect:", error);
}
}
return ( <button onClick={() => handleDisconnect(redirectPath)}>Disconnect</button> )
}