-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathliveblocks.config.ts
More file actions
42 lines (35 loc) · 1.13 KB
/
liveblocks.config.ts
File metadata and controls
42 lines (35 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { createClient } from "@liveblocks/client";
import { createRoomContext } from "@liveblocks/react";
// Check for the API key in the environment variables
const PUBLIC_API_KEY = process.env.NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY;
if (typeof window !== "undefined" && !PUBLIC_API_KEY?.startsWith("pk_")) {
console.warn(
"Liveblocks API key is missing or invalid. Please add NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY to your .env.local file."
);
}
// Create the Liveblocks client
const client = createClient({
publicApiKey: PUBLIC_API_KEY || "pk_dummy_key_please_replace",
});
// Configure Liveblocks types for our Planning Poker room
export type Presence = {
selectedCard: string | null;
name: string | null;
// We can add cursor coordinates etc. later if we want
};
export type Storage = {
isRevealed: boolean;
};
export type RoomEvent = {
type: "NUDGE";
};
// Export the Typed Hooks for our React components
export const {
useMyPresence,
useOthers,
useStorage,
useMutation,
useBroadcastEvent,
useEventListener,
RoomProvider,
} = createRoomContext<Presence, Storage, any, RoomEvent>(client);