jamesJ
Convex Community8mo ago
3 replies
james

Presence in Convex

I wrote a little presence component that you can use directly in your Convex apps, or copy the code to change as you see fit: https://www.convex.dev/components/presence.

It's written in such a way that subscription updates within a "room" are only sent whenever someone joins/leaves, not on every heartbeat. It also shares the same cached subscription for everyone in the room so only issues a single database read. I've set it up so it marks a user as offline immediately whenever they lose visibility state or close the browser tab, but it also disconnects them after a timeout if the connection fails somehow.

Demo: https://presence.previews.convex.dev/
Source code: https://github.com/get-convex/presence/
presence.gif
GitHub
Convex presence component. Contribute to get-convex/presence development by creating an account on GitHub.
GitHub - get-convex/presence: Convex presence component
Was this page helpful?