@kilichat/react 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +79 -2
- package/dist/index.cjs +969 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +273 -0
- package/dist/index.d.ts +273 -0
- package/dist/index.js +900 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +2 -0
- package/package.json +78 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kili
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @kilichat/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React SDK for the Kili customer support chat widget. Add it to your app so your
|
|
4
|
+
users can chat with your support team.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @kilichat/react
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`react` and `react-dom` v18 or v19 are peer dependencies.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Render `KiliChat` and import the stylesheet once:
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { KiliChat } from "@kilichat/react";
|
|
20
|
+
import "@kilichat/react/styles.css";
|
|
21
|
+
|
|
22
|
+
export function Support() {
|
|
23
|
+
return (
|
|
24
|
+
<KiliChat
|
|
25
|
+
config={{
|
|
26
|
+
apiBaseUrl: "https://api.example.com",
|
|
27
|
+
apiKey: "<your api key>",
|
|
28
|
+
apiSecret: "<your api secret>",
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
On mount, `KiliChat` creates or restores the customer for this browser, signs
|
|
36
|
+
them in, loads their conversations and opens a realtime connection. The widget
|
|
37
|
+
fills the full viewport height, so give it its own page or wrap it in a
|
|
38
|
+
container you size yourself.
|
|
39
|
+
|
|
40
|
+
In Next.js, render it from a client component. The package already marks its
|
|
41
|
+
code with `"use client"`.
|
|
42
|
+
|
|
43
|
+
### Config
|
|
44
|
+
|
|
45
|
+
| Option | Required | Description |
|
|
46
|
+
| --------------- | -------- | ---------------------------------------------------- |
|
|
47
|
+
| `apiBaseUrl` | yes | Base URL of the Kili API. |
|
|
48
|
+
| `socketBaseUrl` | no | Base URL of the realtime server. Defaults to `apiBaseUrl`. |
|
|
49
|
+
| `apiKey` | yes | Your organisation's API key. |
|
|
50
|
+
| `apiSecret` | yes | Your organisation's API secret. |
|
|
51
|
+
|
|
52
|
+
## Styling
|
|
53
|
+
|
|
54
|
+
`@kilichat/react/styles.css` holds the widget's styles and its Space Grotesk and DM
|
|
55
|
+
Sans fonts, which load from Google Fonts. Every rule is scoped to the widget's
|
|
56
|
+
root element (`.kili-root`), so the stylesheet does not change the rest of your
|
|
57
|
+
page.
|
|
58
|
+
|
|
59
|
+
For the dark theme, add a `dark` class to the widget's root or to any ancestor,
|
|
60
|
+
such as `<html>`.
|
|
61
|
+
|
|
62
|
+
## Building your own layout
|
|
63
|
+
|
|
64
|
+
`KiliChat` is the simplest option. To compose the widget yourself, call
|
|
65
|
+
`configureKili(config)` first, wrap your tree in `AppStateProvider`, and use any
|
|
66
|
+
of these exports:
|
|
67
|
+
|
|
68
|
+
- `ChatWidget`, `ChatHome`, `ChatThread`, `InitialsAvatar`, `Button`, `Textarea`
|
|
69
|
+
- `AppStateProvider` and `useApp`
|
|
70
|
+
- `SocketProvider`
|
|
71
|
+
- `chatService` and `coreService`
|
|
72
|
+
- the `SocketEvent` constants and the `Chat`, `Message` and `Customer` types
|
|
73
|
+
|
|
74
|
+
`ChatWidget` adds the `kili-root` class itself. If you render the smaller
|
|
75
|
+
components without it, put them inside an element with `className="kili-root"`
|
|
76
|
+
so the styles apply.
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
MIT
|