Overview
The Suada Vanilla JavaScript SDK provides a framework-agnostic way to integrate Suada’s AI capabilities into any web application. Built with modern JavaScript practices, it offers a lightweight, zero-dependency solution that works seamlessly in any browser environment.Prerequisites
- Modern browsers (Chrome 60+, Firefox 60+, Safari 12+, Edge 79+)
- Node.js 16.0.0 or higher (for npm installation)
- A Suada API key
- Basic understanding of JavaScript and DOM manipulation
Installation
Choose the installation method that best suits your project:NPM Installation
CDN Installation
Add the following script tag to your HTML:Quick Start
Here’s a basic example to get you started:Authentication
Setting up your API Key
For development, you can use your API key directly:Configuration Options
Core Components
Chat Component
A pre-built chat interface:Options
Integration Components
Integration Button
Create OAuth integration buttons:Client API
Chat Methods
Send and receive messages:Integration Methods
Manage integrations programmatically:Error Handling
The SDK provides comprehensive error handling:Styling
Using CSS Variables
Customize the appearance using CSS variables:Custom CSS Classes
Override default styles with custom classes:Best Practices
Security
- Store API keys securely
- Implement proper CORS settings
- Use privacy mode for sensitive data
- Secure OAuth callback endpoints
Performance
- Clean up components when not in use
- Implement proper error handling
- Use debouncing for user input
- Optimize network requests
Development
- Follow JavaScript best practices
- Implement proper error boundaries
- Use TypeScript for better type safety
- Keep dependencies updated
FAQ
How do I handle CORS issues?
Configure your server to allow requests from your domain:How do I implement retry logic?
Configure retry behavior in the client:How do I handle rate limiting?
Implement exponential backoff:How can I debug the SDK?
Enable debug mode and use the logger:How do I implement custom authentication?
Use the auth provider option:Support & Resources
Documentation
Support
- Email Support: hello@suada.ai