@lynkoria/react 0.1.0 → 0.1.2
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 +17 -0
- package/README.md +56 -8
- package/package.json +3 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @lynkoria/react
|
|
2
|
+
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c1c6ff1: README: the client needs no API URL (pass your backend's whole `messagingToken()` result), and calls-only apps can use `createLynkoria()` with no options.
|
|
8
|
+
- Updated dependencies [0ee4045]
|
|
9
|
+
- @lynkoria/client@0.2.0
|
|
10
|
+
|
|
11
|
+
## 0.1.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 349320f: READMEs now cover install, requirements and a quick start, list the main API, and link to the documentation at lynkoria.com/docs.
|
|
16
|
+
- Updated dependencies [349320f]
|
|
17
|
+
- @lynkoria/client@0.1.1
|
package/README.md
CHANGED
|
@@ -1,20 +1,68 @@
|
|
|
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
|
+
// Return your backend's whole messagingToken() result; it carries the API URL.
|
|
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
|
+
}
|
|
40
|
+
|
|
41
|
+
// Calls only? createLynkoria() with no options works with LynkoriaProvider and useCall; it opens no
|
|
42
|
+
// messaging connection.
|
|
14
43
|
|
|
15
44
|
function Chat({ conversationId }: { conversationId: string }) {
|
|
16
|
-
const { messages,
|
|
45
|
+
const { messages, loading, hasMore, loadOlder, send } = useConversation(conversationId);
|
|
17
46
|
const presence = usePresence('user_456');
|
|
18
|
-
|
|
47
|
+
// render messages, call send('Hello'), show presence?.status
|
|
19
48
|
}
|
|
20
49
|
```
|
|
50
|
+
|
|
51
|
+
## Hooks
|
|
52
|
+
|
|
53
|
+
| Hook | Returns |
|
|
54
|
+
| --------------------------- | -------------------------------------------------------------------------------------------- |
|
|
55
|
+
| `useLynkoria()` | The client from the provider |
|
|
56
|
+
| `useConnectionState()` | `idle`, `connecting`, `connected`, `reconnecting` or `disconnected` |
|
|
57
|
+
| `useConversation(id)` | `{ messages, loading, error, hasMore, loadOlder, send, markRead }`, ordered and deduplicated |
|
|
58
|
+
| `usePresence(userId)` | Latest presence or `null` |
|
|
59
|
+
| `useTyping(conversationId)` | User IDs currently typing |
|
|
60
|
+
| `useCall()` | `{ session, state, error, join, leave }`; leaves on unmount |
|
|
61
|
+
| `useCallParticipants(s)` | Live participants of a call session |
|
|
62
|
+
|
|
63
|
+
Render a call by passing `session.room` to `@livekit/components-react`. Details and edge cases are in the
|
|
64
|
+
[React SDK guide](https://lynkoria.com/docs/react-sdk/).
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
[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.2",
|
|
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.
|
|
26
|
+
"@lynkoria/client": "0.2.0",
|
|
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.
|
|
39
|
+
"@lynkoria/client": "^0.2.0",
|
|
40
40
|
"react": "^18.2.0 || ^19.0.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|