User
data type in the database by adding a name
and a profile image
.
Go to the Data tab and create two new fields:
name
of type text
profile image
of type image
View all fields
and Find in searches
for everyone.
⚠️ In a production app, be more careful with privacy settings to protect user data.
presence-tutorial
.
column
instead of fixed
.
hidden popup
.
liveblocks-presence
and drag it into the popup to track who’s online.
floating group
that will later house our repeating group for avatars.
Search for floating group
in your assets and drag it onto the page. In the Appearance tab, set the following:
top
left
above elements
make this element fixed-width
and fixed-height
. Set the min-width
to 100% and min-height
to 100px, then check fit height to content
.
repeating group
from the assets to the floating group
. Set the type of content to text
and the data source to Liveblocks-presence (testing) A's everyone
. This data source holds all users in the room, including the local user.
In the Appearance tab, set the following:
set fixed number of rows
rows
to 1set fixed number of columns
minimum width of the column
to 20%separators
to none
border
to none
cell's container layout
to column
container alignment
to top
element is visible on page load
make this element fixed-width
make this element fixed-height
min height
to 0fit height to content
group user
that will display the profile image of users when they are on the page.
Add a group to the repeating group, name it group user
, and set the type of content to user
.
do a search for
, make the type user
, and set the unique id to current cell's text
. This data source is a list of user IDs (which we’ll set later), matching Bubble’s unique IDs.
image
element to the group user
and set the image to Parent group's user's profile image
. Enable Imgix and the following settings:
auto enhance the image
quality
to 100resize to fit dimensions by cropping
apply a circle/ellipse mask
solid color #177db4e
and set a tooltip to display the parent group's user's name
.
keep element aspect ratio fixed
, and set the aspect ratio to 1x1
.
Liveblocks - create room
action. Set the Room ID
to tutorial
and the Default Access
to public
.
Add a new event: When page is loaded
.
Liveblocks - create room
action.
on page load
workflow—we won’t need it anymore since our room is created.
page is loaded
workflow. We will add an action to set the state of an element. In Bubble, states allow you to store information within elements. For this demo, we’ll use states to store a random user ID from our database to simulate a random user. In a real production app, you’d use the current user’s unique ID, but we’re avoiding login for this tutorial.
Add a new action to set the state of an element:
presence-tutorial
, then create a new custom state:
User ID
and make it of type text
.
authorize user
action—this authorizes users in Bubble with Liveblocks.
user ID
field, use the User ID
state we just created.Room ID
, use the tutorial
room you created.permissions
to FULL_ACCESS
.create client
action—this creates an instance of Liveblocks in Bubble. The ID token
is the result of the user you just authorized. You can leave throttle
and lost connection time
as is. Learn more about the parameters of the create client
action here.
enter room
action. This is what joins the user in the room. Enter the Room ID
and User ID
, and keep the rest as default. Learn more about the advanced settings (e.g., live cursors) in this tutorial.
preview
and you should see the page load with your avatar at the top. Open several tabs to see the users on the page update in real time!