> For the complete documentation index, see [llms.txt](https://docs.cometh.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cometh.io/integrations/react-hooks/usedisconnect.md).

# useDisconnect

## Description

This hook provides functionality for disconnecting from a smart account. It handles the disconnection process and manages related states, such as whether the process is pending or if an error occurred. The hook can execute both synchronously and asynchronously.

## Returns

The `useDisconnect` hook returns an object containing the following properties and functions:

* **disconnect** (`() => void`): A synchronous function to disconnect from the smart account. It manages internal states such as pending and error states.
* **disconnectAsync** (`() => Promise<void>`): An asynchronous function to disconnect from the smart account, returning a promise. This function allows the use of `async/await` syntax for handling the disconnection process.
* **isPending** (`boolean`): A boolean indicating whether the disconnection process is currently pending.
* **error** (`Error | null`): An error object if an error occurred during the disconnection process, otherwise `null`.

## Example

```tsx
import React from 'react';
import { useDisconnect } from "@cometh/connect-react-hooks";

const DisconnectButton = () => {
  const { disconnect, isPending, error } = useDisconnect();

  return (
    <div>
      <button onClick={disconnect} disabled={isPending}>
        {isPending ? 'Disconnecting...' : 'Disconnect'}
      </button>
      {error && <p style={{ color: 'red' }}>Error: {error.message}</p>}
    </div>
  );
};

export default DisconnectButton;

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.cometh.io/integrations/react-hooks/usedisconnect.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
