@@ -110,42 +110,9 @@ function App() {
110110
111111## Embedding Methods
112112
113- ### 1. Data Attributes
113+ ### 1. Custom Element (Recommended)
114114
115- The simplest way to embed the widget using HTML data attributes:
116-
117- ``` html
118- <div
119- data-client-widget =" VapiWidget"
120- data-public-key =" pk_123"
121- data-assistant-id =" asst_456"
122- data-mode =" voice"
123- data-theme =" dark"
124- data-size =" compact"
125- ></div >
126- ```
127-
128- ### 2. JSON Props
129-
130- Pass complex configuration using JSON in the ` data-props ` attribute:
131-
132- ``` html
133- <div
134- data-client-widget =" VapiWidget"
135- data-props =' {
136- "publicKey": "pk_123",
137- "assistantId": "asst_456",
138- "mode": "hybrid",
139- "theme": "light",
140- "accentColor": "#3B82F6",
141- "requireConsent": true
142- }'
143- ></div >
144- ```
145-
146- ### 3. Custom Element
147-
148- Use the widget as a custom HTML element with kebab-case attributes:
115+ Use the widget as a custom HTML element with kebab-case attributes - the cleanest and most modern approach:
149116
150117``` html
151118<vapi-widget
@@ -158,23 +125,19 @@ Use the widget as a custom HTML element with kebab-case attributes:
158125></vapi-widget >
159126```
160127
161- ### 4. Programmatic
128+ ### 2. Data Attributes
162129
163- Create widgets dynamically with JavaScript :
130+ Use this approach if your environment doesn't support custom elements or for better compatibility with older systems :
164131
165132``` html
166- <div id =" my-widget" ></div >
167- <script >
168- new WidgetLoader ({
169- container: ' #my-widget' ,
170- component: ' VapiWidget' ,
171- props: {
172- publicKey: ' pk_123' ,
173- vapiConfig: ' asst_456' ,
174- mode: ' hybrid' ,
175- },
176- });
177- </script >
133+ <div
134+ data-client-widget =" VapiWidget"
135+ data-public-key =" pk_123"
136+ data-assistant-id =" asst_456"
137+ data-mode =" voice"
138+ data-theme =" dark"
139+ data-size =" compact"
140+ ></div >
178141```
179142
180143## Usage Examples
@@ -269,31 +232,6 @@ npm run dev
269232
270233Visit < http://localhost:5173 > to see the example app.
271234
272- ## Project Structure
273-
274- ```
275- @vapi-ai/client-sdk-react/
276- ├── src/
277- │ ├── components/ # React components
278- │ │ ├── VapiWidget.tsx # Main widget component
279- │ │ ├── AnimatedStatusIcon.tsx
280- │ │ └── ConsentForm.tsx
281- │ ├── hooks/ # Custom React hooks
282- │ │ ├── useVapiWidget.ts
283- │ │ ├── useVapiCall.ts
284- │ │ └── useVapiChat.ts
285- │ ├── widget/ # Widget loader for embedding
286- │ │ └── index.ts # WidgetLoader class
287- │ ├── styles/ # Global styles
288- │ └── utils/ # Utility functions
289- ├── example/ # Example application
290- ├── dist/ # Built files
291- │ ├── index.js # React library (ES)
292- │ ├── index.cjs # React library (CommonJS)
293- │ └── widget.umd.js # Embeddable widget
294- └── docs/ # Documentation
295- ```
296-
297235## Browser Support
298236
299237- Chrome/Edge 79+
@@ -307,10 +245,6 @@ Visit <http://localhost:5173> to see the example app.
307245- HTTPS required in production
308246- VAPI account and API key
309247
310- ## License
311-
312- ISC
313-
314248## Contributing
315249
3162501 . Fork the repository
0 commit comments