> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hermis.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Disconnect Wallet

> How to disconnect from wallets

## Basic Disconnect

```tsx theme={null}
import { useWallet } from '@hermis/solana-headless-react';

function DisconnectButton() {
  const { disconnect, disconnecting } = useWallet();

  return (
    <button onClick={disconnect} disabled={disconnecting}>
      {disconnecting ? 'Disconnecting...' : 'Disconnect'}
    </button>
  );
}
```

## With Cleanup

```tsx theme={null}
function WalletComponent() {
  const { disconnect, connected } = useWallet();

  const handleDisconnect = async () => {
    try {
      await disconnect();

      // Clear local state
      localStorage.removeItem('user-data');

      // Redirect or update UI
      window.location.href = '/';
    } catch (error) {
      console.error('Disconnect failed:', error);
    }
  };

  return (
    connected && <button onClick={handleDisconnect}>Disconnect</button>
  );
}
```

## Vanilla JavaScript

```javascript theme={null}
await manager.disconnect();
console.log('Disconnected');
```

## Automatic Cleanup

```tsx theme={null}
useEffect(() => {
  return () => {
    // Cleanup on unmount
    if (connected) {
      disconnect();
    }
  };
}, [connected, disconnect]);
```
