> For the complete documentation index, see [llms.txt](https://docs.zama.org/protocol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zama.org/protocol/sdk/api-references/react/usequit.md). Agents can also search and read this documentation through its [MCP server](https://docs.zama.org/protocol/~gitbook/mcp).

# useQuit

Mutation hook that takes the signer's deposit back from a pending or canceled vault batch.

Mutation hook that takes the signer's deposit back from a pending or canceled batch. Wraps [`VaultClient.quit`](https://docs.zama.org/protocol/sdk/api-references/sdk/vaultclient.md#quit). The signer must be the account that joined.

{% hint style="warning" %}
**Quit every leg of a group join, not only the chosen one.** Quitting one leg shows which vault the user picked. See [A group hides which vault you chose](https://docs.zama.org/protocol/sdk/vaults/vaults.md#a-group-hides-which-vault-you-chose).
{% endhint %}

## Import

```ts
import { useQuit } from "@zama-fhe/react-sdk/vaults";
```

## Usage

{% tabs %}
{% tab title="CancelJoinButton.tsx" %}

```tsx
import { useQuit } from "@zama-fhe/react-sdk/vaults";
import type { BatchRef } from "@zama-fhe/sdk/vaults";

function CancelJoinButton({ batches }: { batches: readonly BatchRef[] }) {
  const quit = useQuit();

  async function handleClick() {
    for (const batch of batches) {
      await quit.mutateAsync(batch);
    }
  }

  return (
    <button disabled={quit.isPending} onClick={handleClick}>
      {quit.isPending ? "Cancelling..." : "Cancel and get it back"}
    </button>
  );
}
```

{% endtab %}
{% endtabs %}

`batches` are the batches of every leg of one join, as returned by [`useDeposit`](https://docs.zama.org/protocol/sdk/api-references/react/usedeposit.md) or [`useRedeem`](https://docs.zama.org/protocol/sdk/api-references/react/useredeem.md).

## Parameters

```ts
import { type UseVaultMutationOptions } from "@zama-fhe/react-sdk/vaults";
```

## Mutation variables

A [`BatchRef`](https://docs.zama.org/protocol/sdk/api-references/sdk/vaultclient.md#batchref), passed to `mutate` / `mutateAsync`.

### chainId

`number`

The chain of the batch to quit.

### batcher

`Address`

The batcher of the batch to quit.

### batchId

`bigint`

The batch to quit.

**Throws:**

* `ChainMismatchError`: the wallet is not on the batch's chain.
* `TransactionRevertedError`: the quit reverted, for example because the batch was dispatched in the meantime.

## Return Type

The `data` property (after a successful mutation) is a `TransactionResult`: `{ txHash, receipt }`.

When the mutation settles, successful or not, the hook invalidates every vault read and every confidential balance.

## Related

* [useBatch](https://docs.zama.org/protocol/sdk/api-references/react/usebatch.md): when `quit` is available
* [useClaim](https://docs.zama.org/protocol/sdk/api-references/react/useclaim.md): claim a finalized batch instead


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zama.org/protocol/sdk/api-references/react/usequit.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
