This guide assumes that you already have installed Liveblocks into your project and that you’re already familiar with Nuxt.js.
Alternatively, you can copy this example and follow the instructions in the README:
Run the following command to install Liveblocks package:
@liveblocks/node
is used from the backend to setup the authentication
endpoint.
Users can only interact with rooms they have access to. You can configure permission access by creating a REST endpoint in your Nuxt app. You will implement your own security and define if the current user has access to a specific room.
One way to create an API endpoint in your Nuxt app is to create a
server middleware to extend Express.
Modify your nuxt.config.js
with the following config.
Then create a file called api.js
at the root of your project and add an
Express endpoint like below.
The userId
used in the authorize
function corresponds to userId used in our APIs when setting permissions (e.g. in create room).
You can use the following example to use data from userId
and userInfo
on the front end.
Here is a diagram that shows how things work behind the scenes:
To connect to Liveblocks, you need to create a Liveblocks client with
[createClient
][] from the front-end and set the authEndpoint
option based on
the path of the endpoint created earlier.
Liveblocks should now be integrated with your product!