Skip to main content

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:
For production, ensure you’re using appropriate environment configuration:

Configuring the Provider

Wrap your application with SuadaProvider:

Core Components

Chat Component

A pre-built chat interface component:

Props

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