Skip to content

Commit e9a8704

Browse files
committed
2 parents 25282d2 + af95a56 commit e9a8704

File tree

1 file changed

+98
-1
lines changed

1 file changed

+98
-1
lines changed

README.md

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

0 commit comments

Comments
 (0)