Skip to content

Commit 4ad48b7

Browse files
BenHavisedgurgel
andauthored
docs: add presence overview section and example payload (supabase#40635)
Adds a brief overview explaining Presence behavior and includes an example presenceState() payload. --------- Co-authored-by: Eduardo Gurgel <[email protected]>
1 parent f905942 commit 4ad48b7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

apps/docs/content/guides/realtime/presence.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,25 @@ Let's explore how to implement Realtime Presence to track state between multiple
1010

1111
You can use the Supabase client libraries to track Presence state between users.
1212

13+
### How Presence works
14+
15+
Presence lets each connected client publish a small piece of state—called a “presence payload”—to a shared channel. Supabase stores each client’s payload under a unique presence key and keeps a merged view of all connected clients.
16+
17+
When any client subscribes, disconnects, or updates their presence payload, Supabase triggers one of three events:
18+
19+
- **`sync`** — the full presence state has been updated
20+
- **`join`** — a new client has started tracking presence
21+
- **`leave`** — a client has stopped tracking presence
22+
23+
The complete presence state returned by `presenceState()` looks like this:
24+
25+
```json
26+
{
27+
"client_key_1": [{ "userId": 1, "typing": false }],
28+
"client_key_2": [{ "userId": 2, "typing": true }]
29+
}
30+
```
31+
1332
### Initialize the client
1433

1534
Go to your Supabase project's [API Settings](/dashboard/project/_/settings/api) and grab the `URL` and `anon` public API key.

0 commit comments

Comments
 (0)