Follow the following steps to start configure your authentication endpoint where
liveblocks/node packageUsers can only interact with rooms they have access to. You can
configure permission access in an api/liveblocks-auth endpoint by
creating the liveblocks-auth.ts file with the
following code. This is where you will implement your security and
define if the current user has access to a specific room.
On the front end, you can now replace the publicApiKey
option with authEndpoint pointing to the endpoint you
just created.
If you need to pass custom headers or data to your endpoint, you can use authEndpoint as a callback instead.
A room can have defaultAccesses, usersAccesses, and groupsAccesses defined.
Permissions are then checked when users try to connect to a room. For security purposes,
room permissions can only be set on the back-end through @liveblocks/node or our REST API.
For instance, you can use liveblocks.createRoom
to create a new room with read-only public access levels while giving write access to specific groups and users.
For more information, make sure to read the section on room permissions.
Both userId and userInfo can then be used in your JavaScript application as
such:

We use cookies to collect data to improve your experience on our site. Read our Privacy Policy to learn more.