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

# Disconnect Wallets on Session End

> Control whether ending a session disconnects wallets remotely or only clears SDK-local state.

Before this: create and initialize a Dynamic client (see [Creating a Dynamic Client](https://www.dynamic.xyz/docs/javascript/reference/client/create-dynamic-client.md)) and read [User and Session Management](https://www.dynamic.xyz/docs/javascript/user-session-management.md).

When a session ends, the SDK does two things to every connected wallet provider: it sends a remote disconnect signal to the wallet (for example `wallet_revokePermissions` for EIP-1193 wallets or session end for WalletConnect wallets), and it cleans up local state and listeners. The remote signal makes the wallet forget the connection, so the user is prompted for wallet permissions again on the next login.

Two options let you skip the remote signal while keeping the local cleanup, so users are not re-prompted:

* `disconnectWallets` on `logout()` and `useLogout()` controls an explicit logout call. It defaults to `true`.
* `disconnectWalletsOnSessionEnd` on `createDynamicClient()` covers every other way a session can end, such as an expiring or revoked session, a failed refresh, or an action that ends authentication like account deletion. It also defaults to `true`.

Setting either option to `false` keeps the wallet-side session alive, so the wallet does not ask for permissions again on the next login. SDK-local state and listeners are always cleaned up regardless of the option.

## Disconnect on explicit logout

Pass `disconnectWallets: false` when calling `logout()` to keep the wallet-side session for that call only:

> [tab] JavaScript
>
> ```javascript theme={"system"} theme={"system"}
>     import { logout } from '@dynamic-labs-sdk/client';
>
>     await logout({ disconnectWallets: false });
> ```

> [tab] React
>
> ```tsx theme={"system"}
>     import { useLogout } from '@dynamic-labs-sdk/react-hooks';
>
>     function LogoutButton() {
>       const { mutate: logout } = useLogout({ disconnectWallets: false });
>       return <button onClick={() => logout()}>Log out</button>;
>     }
> ```

An explicit `disconnectWallets` value always wins for that call: `logout({ disconnectWallets: false })` skips the remote signal even when `disconnectWalletsOnSessionEnd` is `true`, and `logout({ disconnectWallets: true })` disconnects even when it is `false`.

## Disconnect on other session ends

Set `disconnectWalletsOnSessionEnd: false` on `createDynamicClient()` to keep wallet-side sessions alive when the session ends without an explicit `logout()` call:

```javascript theme={"system"} theme={"system"}
import { createDynamicClient } from '@dynamic-labs-sdk/client';

const dynamicClient = createDynamicClient({
  environmentId: 'YOUR_ENVIRONMENT_ID',
  disconnectWalletsOnSessionEnd: false,
});
```

The config flag does not affect explicit `logout()` calls; those follow the `disconnectWallets` param described above and disconnect by default.

> [!NOTE]
>
> Keeping the wallet-side session alive means the wallet still remembers the granted permissions. Whether the wallet reuses that session on the next connect is up to the wallet; some wallets always show a connect prompt regardless of prior permissions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.