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

# Follows

> Follow and unfollow users, and read follower lists and counts.

## Follow state

```tsx theme={null}
import { useFollowStatus, useFollow, useUnfollow } from '@cskn/sdk';

function FollowButton({ userId }: { userId: string }) {
  const { data: status } = useFollowStatus(userId);
  const follow = useFollow();
  const unfollow = useUnfollow();

  if (!status) return null;
  return status.isFollowing ? (
    <button onClick={() => unfollow.mutate(userId)}>Following</button>
  ) : (
    <button onClick={() => follow.mutate(userId)}>{status.isFollower ? 'Follow back' : 'Follow'}</button>
  );
}
```

| Hook | Returns |
| - | - |
| `useFollowStatus(targetUserId)` | `{ isFollowing, isFollower, isMutual }` |
| `useIsFollowing(targetUserId)` | `{ isFollowing }` |
| `useFollowStats(username)` | `{ followersCount, followingCount }` |
| `useFollow()` | Mutation; pass the target user id. |
| `useUnfollow()` | Mutation; pass the target user id. |

Both mutations invalidate the follow-state and list queries for you.

## Lists

```tsx theme={null}
import { useFollowers, useFollowing } from '@cskn/sdk';

const { data } = useFollowers('ada', { limit: 20, offset: 0 });
// data: { users: FollowUser[]; total: number; hasMore: boolean }
```

Omit the username for the signed-in user's own lists. Each `FollowUser` is `{ _id, username, name, picture? }`.

## Plain functions

`getFollowStatus`, `getFollowStats`, `getIsFollowing`, `getFollowers`, `getFollowing`, `followUser` and `unfollowUser` are exported for use outside React.


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