React + tiny bit LiveView?

First, I know this question is whacky, but bear with me.
I wanted to know if there’s a way to render liveview on a React frontend(NextJS).

Here’s a little scenario:
Suppose I want to implement a “users online” counter on my website. The website is in React, so I think, what if I use liveview to render this counter inside a component and I can just plug this component inside my react codebase, and it would just work?

Is this doable? If yes, how should I go on about making it?

Alternatively, what other approach you can take if you were to make the same thing?

You can use Phoenix Channels / Presence to achieve the above.

Like this:

There is a library, and probably more than one that you can use, for example this one provides the usePresence hook that may be useful:


Awesome! I’ll check those out. Thanks!