@lynkoria/react 0.1.0 → 0.1.1
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.
- package/CHANGELOG.md +9 -0
- package/README.md +53 -8
- package/package.json +3 -3
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -1,20 +1,65 @@
|
|
|
1
1
|
# @lynkoria/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@lynkoria/react)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
|
|
6
|
+
React hooks for Lynkoria messaging, presence, typing and calls, built on
|
|
7
|
+
[`@lynkoria/client`](https://www.npmjs.com/package/@lynkoria/client). The hooks manage state and
|
|
8
|
+
subscriptions; the UI stays yours.
|
|
9
|
+
|
|
10
|
+
**[Documentation](https://lynkoria.com/docs/)** · [React SDK guide](https://lynkoria.com/docs/react-sdk/) ·
|
|
11
|
+
[Next.js](https://lynkoria.com/docs/nextjs/) · [TanStack Start](https://lynkoria.com/docs/tanstack/)
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @lynkoria/react @lynkoria/client
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Peer dependencies: `react` (18 or 19) and `@lynkoria/client`. For prebuilt call UI, add
|
|
20
|
+
`@livekit/components-react` and `@livekit/components-styles`.
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
4
23
|
|
|
5
24
|
```tsx
|
|
6
25
|
import { createLynkoria } from '@lynkoria/client';
|
|
7
|
-
import { LynkoriaProvider, useConversation, usePresence
|
|
26
|
+
import { LynkoriaProvider, useConversation, usePresence } from '@lynkoria/react';
|
|
8
27
|
|
|
9
|
-
const client = createLynkoria({
|
|
28
|
+
const client = createLynkoria({
|
|
29
|
+
baseUrl: 'https://api.lynkoria.com',
|
|
30
|
+
getMessagingToken: () => myBackend.fetchLynkoriaMessagingToken(),
|
|
31
|
+
});
|
|
10
32
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
33
|
+
export function App() {
|
|
34
|
+
return (
|
|
35
|
+
<LynkoriaProvider client={client}>
|
|
36
|
+
<Chat conversationId="conv_123" />
|
|
37
|
+
</LynkoriaProvider>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
14
40
|
|
|
15
41
|
function Chat({ conversationId }: { conversationId: string }) {
|
|
16
|
-
const { messages,
|
|
42
|
+
const { messages, loading, hasMore, loadOlder, send } = useConversation(conversationId);
|
|
17
43
|
const presence = usePresence('user_456');
|
|
18
|
-
|
|
44
|
+
// render messages, call send('Hello'), show presence?.status
|
|
19
45
|
}
|
|
20
46
|
```
|
|
47
|
+
|
|
48
|
+
## Hooks
|
|
49
|
+
|
|
50
|
+
| Hook | Returns |
|
|
51
|
+
| --------------------------- | -------------------------------------------------------------------------------------------- |
|
|
52
|
+
| `useLynkoria()` | The client from the provider |
|
|
53
|
+
| `useConnectionState()` | `idle`, `connecting`, `connected`, `reconnecting` or `disconnected` |
|
|
54
|
+
| `useConversation(id)` | `{ messages, loading, error, hasMore, loadOlder, send, markRead }`, ordered and deduplicated |
|
|
55
|
+
| `usePresence(userId)` | Latest presence or `null` |
|
|
56
|
+
| `useTyping(conversationId)` | User IDs currently typing |
|
|
57
|
+
| `useCall()` | `{ session, state, error, join, leave }`; leaves on unmount |
|
|
58
|
+
| `useCallParticipants(s)` | Live participants of a call session |
|
|
59
|
+
|
|
60
|
+
Render a call by passing `session.room` to `@livekit/components-react`. Details and edge cases are in the
|
|
61
|
+
[React SDK guide](https://lynkoria.com/docs/react-sdk/).
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
[Apache-2.0](./LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynkoria/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React hooks for Lynkoria calls, messages and presence",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@lynkoria/client": "0.1.
|
|
26
|
+
"@lynkoria/client": "0.1.1",
|
|
27
27
|
"@lynkoria/config": "0.0.0",
|
|
28
28
|
"@testing-library/react": "^16.3.3",
|
|
29
29
|
"@types/react": "^19.3.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"vitest": "^5.1.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@lynkoria/client": "^0.1.
|
|
39
|
+
"@lynkoria/client": "^0.1.1",
|
|
40
40
|
"react": "^18.2.0 || ^19.0.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|