# RoomDefinition: seesPresence() hook

> The seesPresence() hook of a room definition decides whether a connection sees another player's presence entry.

The **`seesPresence()`** hook of a [room definition](/docs/room/room-definition) decides whether a connection sees another player's [presence entry](/docs/room/presence-entry), such as to hide players it blocked. Without it, every connection sees every player's presence.

## Syntax

```ts
defineRoom({
  seesPresence(room, viewer, entry) {},
});
```

### Parameters

`room`
: The [`Room`](/docs/room/room).

`viewer`
: The [`Connection`](/docs/room/connection) that would see the entry.

`entry`
: The [`PresenceEntry`](/docs/room/presence-entry) of another player.

### Return value

`true` if `viewer` sees `entry`, else `false`.

### Exceptions

If `seesPresence` throws, the room stops and its connections close with close code 4007, as for an error in interest.

## Description

The room calls `seesPresence` at each state update, for each connection and each other player's entry, so keep it cheap. A player always sees its own entry, and `seesPresence` isn't called for it. A viewer sees another player's entry only while `seesPresence` returns `true`.

Presence doesn't follow [`interest`](/docs/room/room-definition/interest): without `seesPresence`, every connection sees every entry, whatever `interest` says. An entry a connection sees counts toward the 16,384 entities it sees.

## Examples

### Hiding blocked players

```ts
// blocking.ts
import { defineRoom } from "@irtio/room";

export default defineRoom({
  onJoin(_room, connection) {
    connection.data.blocked = new Set<string>();
  },
  onMessage(_room, connection, message) {
    const m = message as { type?: string; player?: unknown };
    if (m.type === "block" && typeof m.player === "string") connection.data.blocked.add(m.player);
  },
  seesPresence(_room, viewer, entry) {
    return !viewer.data.blocked?.has(entry.player);
  },
});
```

## See also

- [`PresenceEntry`](/docs/room/presence-entry)
- [Presence](/docs/room/guides/presence)
