Like this?
https://github.com/NodeBB/nodebb-widget-essentials/blob/master/public/templates/widgets/activeusers.tpl
This pre-renders the list of active users from server data. And then has some inline JS with socket call to update the list as new users become active