@jexity/chat-widget 0.1.0 → 0.2.0-canary.6b459f2

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/README.md CHANGED
@@ -20,13 +20,32 @@ npm install @jexity/chat-widget
20
20
  ```
21
21
 
22
22
  ```ts
23
- import { init } from '@jexity/chat-widget'
23
+ import { JexityChat } from '@jexity/chat-widget'
24
24
 
25
- const widget = init({
25
+ const chat = JexityChat({
26
26
  orgId: 'YOUR_ORG_ID',
27
27
  })
28
28
 
29
- // Later: widget.destroy()
29
+ // Later: chat.shutdown()
30
+ ```
31
+
32
+ ### React Provider
33
+
34
+ ```tsx
35
+ import { JexityChatProvider, useJexityChat } from '@jexity/chat-widget/react'
36
+
37
+ function App() {
38
+ return (
39
+ <JexityChatProvider orgId="YOUR_ORG_ID">
40
+ <HomePage />
41
+ </JexityChatProvider>
42
+ )
43
+ }
44
+
45
+ function HomePage() {
46
+ const { open, close, toggle, isOpen } = useJexityChat()
47
+ return <button onClick={open}>Chat with us</button>
48
+ }
30
49
  ```
31
50
 
32
51
  ## Configuration
@@ -44,12 +63,23 @@ const widget = init({
44
63
  ## Programmatic API
45
64
 
46
65
  ```ts
47
- const widget = init(options)
66
+ const chat = JexityChat(options)
48
67
 
49
- widget.open() // Open the chat window
50
- widget.close() // Close the chat window
51
- widget.toggle() // Toggle open/closed
52
- widget.destroy() // Remove widget from DOM
68
+ chat.open() // Open the chat window
69
+ chat.close() // Close the chat window
70
+ chat.toggle() // Toggle open/closed
71
+ chat.shutdown() // Remove widget from DOM
72
+ chat.isOpen // readonly boolean
73
+ ```
74
+
75
+ ## Script Tag Global
76
+
77
+ ```html
78
+ <script src="https://cdn.jexity.chat/widget/latest/widget.js" data-org-id="YOUR_ORG_ID"></script>
79
+ <script>
80
+ window.JexityChat.open()
81
+ window.JexityChat.shutdown()
82
+ </script>
53
83
  ```
54
84
 
55
85
  ## License