Comments - Users and mentions
When a comment is posted, Liveblocks doesn’t store any user or group metadata, for example their avatar or name. Instead, it only saves their user ID, which you manually set when authenticating. To fetch user and group metadata, we provide functions that allow you to return the correct data.

Authenticate your users
You can set a user’s ID when authenticating your application, for example with
liveblocks.prepareSession
.
This ID is then used inside Comments to represent the current user, for example
we’re using an email address as a user ID below.
There are two different authentication methods—make sure to follow an authentication guide for your framework to get started.
Adding user information to Comments
In Comments, user information is retrieved from a list of user IDs, for example
here’s a userIds
array and the information you need to return. You should
return the same number of users as the number of user IDs, in the same order.
Add a property named
resolveUsers
to your
LiveblocksProvider
where you can return this information.
The name
, and avatar
are handled by the default components, but you can also
return custom metadata here. For example, each user may have a color
property.
You can retrieve these properties in your app with
useUser
.
Adding group information to Comments
You can also adds groups to Comments, allowing you to tag a team of people with one mention. Similar to users, group information is retrieved from a list of group IDs. You should return the same number of groups as the number of group IDs, in the same order.
Add a property named
resolveGroupsInfo
to your
LiveblocksProvider
where you can return this information.
The name
and avatar
are handled by the default components, but you can also
also return custom metadata here. For example, each group may have a color
property. You can retrieve these properties in your app with
useGroupInfo
.
Resolving user and group mentions suggestions
Comments allows you to search for users and groups after typing the "@"
character.

When a user types "@"
and searches for a user or group, Comments will pass you
a text
property which you can use to return matching user IDs and group IDs.
You can resolve these search results by adding a
resolveMentionSuggestions
property to your
LiveblocksProvider
.
Here's what the function might look like if the user has typed "@mar"
into the
input.
User mentions only
User and group mentions
To support both user and group mentions, you can return a list of mention objects instead of just user IDs. This allows you to suggest a mix of users and groups.
If a user has only typed "@"
, text
is an empty string, and it's recommended
to return every user and group.