Skip to content

Commit 8f3b6bd

Browse files
authored
Update README.md
1 parent 5b0e5fb commit 8f3b6bd

File tree

1 file changed

+96
-1
lines changed

1 file changed

+96
-1
lines changed

README.md

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,96 @@
1-
# liveblocks-javascript-authentication
1+
# Liveblocks JavaScript Authentication
2+
3+
This repository provides a simple implementation of user authentication for Liveblocks using JavaScript. Liveblocks is a platform that enables real-time collaborative experiences in web applications. This example demonstrates how to authenticate users and manage access to rooms.
4+
5+
## Features
6+
7+
- Generate unique user IDs for session management.
8+
- Manage user access to different rooms based on organization and group.
9+
- Simple integration with Liveblocks for real-time collaboration.
10+
- Example frontend and backend implementation.
11+
12+
## Prerequisites
13+
14+
Before you begin, ensure you have met the following requirements:
15+
16+
- [Node.js](https://nodejs.org/) installed on your machine (version 14 or later).
17+
- A Liveblocks account and a valid secret key.
18+
19+
## Installation
20+
21+
Clone the repository:
22+
23+
```bash
24+
git clone https://github.com/BaseMax/liveblocks-javascript-authentication.git
25+
cd liveblocks-javascript-authentication
26+
```
27+
28+
Install the dependencies:
29+
30+
```bash
31+
npm install
32+
```
33+
34+
Start the backend server:
35+
36+
```bash
37+
node auth.js
38+
```
39+
40+
Run `npm run dev` and open the URL in the browser to see the frontend in action.
41+
42+
## Usage
43+
44+
Click the "Connect to Room" button in the frontend to initiate a connection to the Liveblocks room.
45+
46+
The backend will handle the authentication process and return the appropriate response to the frontend.
47+
48+
The frontend will update the status of connected users in real-time.
49+
50+
## Folder Structure
51+
52+
```
53+
liveblocks-javascript-authentication/
54+
├── .gitignore
55+
├── auth.js # Backend authentication logic
56+
├── index.html # Frontend HTML file
57+
├── package.json # Node.js dependencies
58+
├── package-lock.json # Lock file for package dependencies
59+
├── README.md # Project documentation
60+
└── room.js # Liveblocks client configuration
61+
```
62+
63+
## API Endpoints
64+
65+
### `POST /api/liveblocks-auth`
66+
67+
Authenticates the user and authorizes access to a Liveblocks room.
68+
69+
Request Body:
70+
71+
```
72+
Copy code
73+
{
74+
"roomId": "string"
75+
}
76+
```
77+
78+
Response:
79+
```
80+
{
81+
"token": "long string"
82+
}
83+
```
84+
85+
- **200 OK:** User is successfully authenticated.
86+
- **400:** Authentication failed due to missing or invalid data.
87+
88+
## License
89+
90+
This project is licensed under the GPL-3.0 License.
91+
92+
## Contributing
93+
94+
Contributions are welcome! Please open an issue or submit a pull request to improve this project.
95+
96+
Copyright 2024, Max Base

0 commit comments

Comments
 (0)