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

# useBlockManager

> High-level hook for managing block state with a single user

`useBlockManager` is a convenience hook for building block/unblock buttons on a user profile. It automatically loads the current block status on mount and exposes a `toggleBlock` function that handles both blocking and unblocking.

Blocking is a trust & safety primitive shipped as part of the **moderation bundle** — the same package that provides reporting and suspensions. See [Moderation — Blocking](/sdk/moderation/overview#blocking) for the full enforcement behavior.

<Note>
  **Requires the `moderation` bundle.** Blocking is available in any project that has the moderation bundle installed. See [Bundles](/bundles) to add it.
</Note>

## Usage Example

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

function BlockButton({ userId }: { userId: string }) {
  const { isBlocked, isLoading, toggleBlock } = useBlockManager({ userId });

  if (isLoading) return <button disabled>...</button>;

  return (
    <button onClick={toggleBlock}>
      {isBlocked ? "Unblock" : "Block"}
    </button>
  );
}
```

## Parameters

<ParamField path="userId" type="string" required>
  The ID of the user to block or unblock. The hook will not run if this equals the current user's ID.
</ParamField>

## Returns

<ResponseField name="isBlocked" type="boolean | null">
  Whether the current user blocks the target user. `null` while the initial status check is in progress.
</ResponseField>

<ResponseField name="isLoading" type="boolean">
  `true` while the initial block status is being fetched.
</ResponseField>

<ResponseField name="toggleBlock" type="() => Promise<void>">
  Blocks the user if not currently blocked, or unblocks if currently blocked. No-ops if loading or if `userId` equals the current user's ID.
</ResponseField>

<Note>
  The current user must be signed in for this hook to function. The hook performs no action if the `userId` matches the authenticated user's own ID.
</Note>

## Related

* [useBlockUser](/hooks/blocks/use-block-user)
* [useUnblockUser](/hooks/blocks/use-unblock-user)
* [useFetchBlockStatus](/hooks/blocks/use-fetch-block-status)
* [useFetchBlockedUsers](/hooks/blocks/use-fetch-blocked-users)
