x currently viewing

is there an easy way to display the current number of people on a page?
3 Replies
Christoph
Christoph17mo ago
I've seen a lot of shops that present fake data on product pages. Other than that, you can implement that using presence. You basically have a channel per page and then output how many clients are currently in said channel. E.g. ably offers such an API.
hyhy
hyhy17mo ago
I was able to do this following this repo (which is a fork of Zapdos with a bunch of stuff removed) https://github.com/zzacong/spritzee-pusher-next/blob/main/src/lib/pusher.tsx requires a bit of setup but the useCurrentMemberCount hook will do what you're looking for
GitHub
spritzee-pusher-next/src/lib/pusher.tsx at main · zzacong/spritzee-...
Realtime websocket NextJS app using Pusher and t3 stack - zzacong/spritzee-pusher-next
hyhy
hyhy17mo ago
you need the pusher.tsx file, the 2 auth api pages in api/pusher, and a pusher provider wrapping the page you want the channel for and some api keys from pusher
Want results from more Discord servers?
Add your server