Overview
The Suada React SDK provides a seamless way to integrate Suada’s AI capabilities into your React applications. Built with modern React practices in mind, it offers hooks, components, and utilities that make it easy to add AI-powered features to your application.Prerequisites
- React 16.8.0 or higher (for Hooks support)
- Node.js 16.0.0 or higher
- A Suada API key
- npm or yarn package manager
Installation
Install the Suada React SDK and its peer dependencies:Quick Start
Here’s a basic example to get you started:Authentication
Setting up your API Key
We recommend storing your API key in environment variables:Configuring the Provider
Wrap your application withSuadaProvider:
Core Components
Chat Component
A pre-built chat interface component:Props
| Prop | Type | Required | Description |
|---|---|---|---|
| theme | ’light’ | ‘dark’ | No | UI theme (defaults to ‘light’) |
| placeholder | string | No | Input placeholder text |
| initialMessages | Message[] | No | Pre-loaded chat messages |
| privacyMode | boolean | No | Enable enhanced privacy features |
| onMessageSubmit | (message: string) => void | Yes | Called when a message is submitted |
| onResponseReceived | (response: Response) => void | Yes | Called when a response is received |
| onError | (error: Error) => void | No | Called when an error occurs |
Integration Components
Integration Manager
The main component for managing integrations:Integration Button
A standalone button for connecting services:Hooks
useSuada
The main hook for accessing Suada functionality:useIntegrations
Manage integrations programmatically:Error Handling
The SDK provides typed errors for better error handling:Best Practices
Security
- Store API keys in environment variables
- Use privacy mode for sensitive data
- Implement proper error boundaries
- Secure OAuth callback endpoints
Performance
- Implement proper cleanup in useEffect
- Use memoization for expensive computations
- Implement proper error boundaries
- Consider implementing request caching
Development
- Use TypeScript for better type safety
- Follow React best practices
- Write unit tests
- Keep dependencies updated
FAQ
How do I handle environment-specific configuration?
Use environment files and ensure they’re properly configured:How do I customize component themes?
You can override the default styles using CSS variables:Can I use the SDK with Next.js?
Yes, the SDK is compatible with Next.js. For server components, use the appropriate imports:How do I implement retry logic?
The SDK includes built-in retry logic that you can configure:How can I debug the SDK?
Enable debug mode in your provider configuration:Support & Resources
Documentation
Support
- Email Support: hello@suada.ai