video-saas-client 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +27 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -8,6 +8,33 @@ Video calling SDK for Video SaaS. Connect to video rooms with token-based authen
8
8
  npm install video-saas-client
9
9
  ```
10
10
 
11
+ ## Getting a token
12
+
13
+ Tokens are generated server-side using [video-saas-admin](https://www.npmjs.com/package/video-saas-admin). Never expose your API key in the browser.
14
+
15
+ 1. **Install the admin package** in your backend:
16
+ ```bash
17
+ npm install video-saas-admin
18
+ ```
19
+
20
+ 2. **Create an API route** that returns a token for a given room (example: Next.js):
21
+ ```js
22
+ // app/api/room-token/route.js
23
+ import { createRoomToken } from "video-saas-admin";
24
+
25
+ export async function GET(request) {
26
+ const roomId = request.nextUrl.searchParams.get("roomId");
27
+ const token = await createRoomToken(roomId, { apiKey: process.env.VIDEO_SAAS_API_KEY });
28
+ return Response.json({ token });
29
+ }
30
+ ```
31
+
32
+ 3. **Fetch the token** on the frontend before joining:
33
+ ```jsx
34
+ const { token } = await fetch(`/api/room-token?roomId=${roomId}`).then(r => r.json());
35
+ useVideoCall(roomId, { token });
36
+ ```
37
+
11
38
  ## Usage
12
39
 
13
40
  ```jsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "video-saas-client",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Video calling SDK for Video SaaS",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",