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

# Leave space

> Leave a space

## Overview

`useLeaveSpace` returns a callable function for leaving a space. The user's membership record is removed.

<Note>When using `SpaceProvider`, call `leaveSpace` from `useSpace` — it handles optimistic state updates automatically.</Note>

## Usage Example

```tsx theme={null}
import { useLeaveSpace } from "@replyke/react-js";

function LeaveButton({ spaceId }: { spaceId: string }) {
  const leaveSpace = useLeaveSpace();

  const handleLeave = async () => {
    await leaveSpace({ spaceId });
  };

  return <button onClick={handleLeave}>Leave</button>;
}
```

## Parameters

<ParamField path="spaceId" type="string" required>
  UUID of the space to leave.
</ParamField>

## Returns

<ResponseField name="message" type="string">
  Confirmation message.
</ResponseField>
