-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathliveblocks.config.ts
45 lines (36 loc) · 1.51 KB
/
liveblocks.config.ts
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
43
44
45
"use client";
import { createClient, LiveMap, LiveObject } from "@liveblocks/client";
import { createRoomContext } from "@liveblocks/react";
const client = createClient({
publicApiKey: process.env.NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY as string,
throttle: 16,
});
// Presence represents the properties that will exist on every User in the Room
// and that will automatically be kept in sync. Accessible through the
// `user.presence` property. Must be JSON-serializable.
type Presence = {};
type File = LiveObject<{
title: string;
description: string;
url: string;
state: "uploading" | "ready" | "deleting";
}>;
type Files = LiveMap<string, File>;
// Optionally, Storage represents the shared document that persists in the
// Room, even after all Users leave. Fields under Storage typically are
// LiveList, LiveMap, LiveObject instances, for which updates are
// automatically persisted and synced to all connected clients.
type Storage = {
files: Files;
};
// Optionally, UserMeta represents static/readonly metadata on each User, as
// provided by your own custom auth backend (if used). Useful for data that
// will not change during a session, like a User's name or avatar.
export type UserMeta = {};
// Optionally, the type of custom events broadcast and listened to in this
// room. Must be JSON-serializable.
type RoomEvent = {};
export const {
suspense: { RoomProvider, useMutation, useStorage },
/* ...all the other hooks you’re using... */
} = createRoomContext<Presence, Storage, UserMeta, RoomEvent>(client);