@customerhero/react 0.0.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/LICENSE +21 -0
- package/README.md +68 -0
- package/dist/index.cjs +916 -0
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +896 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CustomerHero
|
|
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
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @customerhero/react
|
|
2
|
+
|
|
3
|
+
Drop-in React component for embedding the [CustomerHero](https://customerhero.app) chat widget.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @customerhero/react @customerhero/js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`react` (>=18) and `@customerhero/js` are peer dependencies.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { ChatWidget } from "@customerhero/react";
|
|
17
|
+
|
|
18
|
+
export function App() {
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
{/* your app */}
|
|
22
|
+
<ChatWidget chatbotId="bot_xxxxxxxxxxxxxxxxxxxx" />
|
|
23
|
+
</>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Identify a signed-in user
|
|
29
|
+
|
|
30
|
+
Pass an `identity` prop to link conversations to a user record in your system. Use a stable `userId` and — in production — a server-signed `userHash` (HMAC-SHA256) to prevent impersonation.
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
<ChatWidget
|
|
34
|
+
chatbotId="bot_xxxxxxxxxxxxxxxxxxxx"
|
|
35
|
+
identity={{
|
|
36
|
+
userId: currentUser.id,
|
|
37
|
+
email: currentUser.email,
|
|
38
|
+
name: currentUser.name,
|
|
39
|
+
userHash: currentUser.chatUserHash,
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Props
|
|
45
|
+
|
|
46
|
+
`ChatWidgetProps` extends [`CustomerHeroChatConfig`](https://www.npmjs.com/package/@customerhero/js) from `@customerhero/js`. Common props:
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Description |
|
|
49
|
+
| ------------------- | --------------------------------- | ----------------------------------------------------------- |
|
|
50
|
+
| `chatbotId` | `string` (required) | The chatbot to connect to. |
|
|
51
|
+
| `identity` | `IdentifyPayload` | Current user identity. Triggers `identify` when it changes. |
|
|
52
|
+
| `apiBase` | `string` | API base URL override. |
|
|
53
|
+
| `primaryColor` | `string` | Accent color. |
|
|
54
|
+
| `backgroundColor` | `string` | Chat window background. |
|
|
55
|
+
| `textColor` | `string` | Text color. |
|
|
56
|
+
| `position` | `"bottom-right" \| "bottom-left"` | Widget position. |
|
|
57
|
+
| `placeholderText` | `string` | Input placeholder. |
|
|
58
|
+
| `welcomeMessage` | `string` | Welcome message. |
|
|
59
|
+
| `title` | `string` | Header title. |
|
|
60
|
+
| `avatarUrl` | `string` | Bot avatar URL. |
|
|
61
|
+
| `locale` | `string` | Widget locale (`"en"`, `"es"`). Auto-detected if omitted. |
|
|
62
|
+
| `suggestedMessages` | `string[]` | Quick-reply options shown before the first message. |
|
|
63
|
+
|
|
64
|
+
See the full reference at [customerhero.app/docs](https://customerhero.app).
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT
|