Skip to content

Commit 8d6ac53

Browse files
committed
update
1 parent 97d167d commit 8d6ac53

3 files changed

Lines changed: 37 additions & 1 deletion

File tree

index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Liveblocks Auth</title>
7+
<script type="module" src="/room.js"></script>
8+
</head>
9+
<body>
10+
<div>
11+
<p id="status">Not connected</p>
12+
<button id="connect">Connect to Room</button>
13+
</div>
14+
15+
<script>
16+
document.getElementById('connect').addEventListener('click', () => {
17+
const { room, leave } = window.client.enterRoom("my-room");
18+
19+
room.subscribe("others", (others) => {
20+
document.getElementById('status').innerText = `There are ${others.length} other user(s) online`;
21+
});
22+
});
23+
</script>
24+
</body>
25+
</html>

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "liveblocks-javascript-authentication",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "room.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "ISC"
11+
}

room.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createClient } from "@liveblocks/client";
22

33
const client = createClient({
44
publicApiKey: "pk_dev_4hBTxoM5Vkir7gRMcIEP99BTDpqay7jjxcG9ELGa4fomzhWfbzkWgOh4qbU4Rhup",
5-
authEndpoint: "/auth.php",
5+
authEndpoint: "http://localhost/auth.php",
66
});
77

88
export const { room, leave } = client.enterRoom("my-room");

0 commit comments

Comments
 (0)