React Native SDK

A customizable WebRTC SDK for React Native that supports Expo. This package provides components for building real-time audio applications with KrosAI in React Native.

πŸš€ Installation

Install required dependencies:

npm install krosai-react-native-sdk react-native-webrtc expo-av expo-permissions @react-native-async-storage/async-storage

For Expo projects, configure the necessary permissions in your app.json:

{
  "expo": {
    "plugins": [
      [
        "expo-av",
        {
          "microphonePermission": "Allow $(PRODUCT_NAME) to access your microphone."
        }
      ]
    ]
  }
}

πŸ› οΈ Usage

Basic Example


πŸ“… Components

⛰️ KrosaiWrapper

The base wrapper component that manages WebRTC connection and audio setup.

Props:

  • url: string – Krosai WebSocket server URL

  • token: string – JWT token for authentication

  • onConnected?: () => void – Callback when successfully connected

  • onDisconnected?: () => void – Callback when disconnected

  • onError?: (error: Error) => void – Callback for connection errors

  • style?: ViewStyle – Custom styles for the container


πŸ—£οΈ VoiceAssistant

A higher-level component that adds voice assistant functionality.

Props:

  • url: string – Krosai WebSocket server URL

  • token: string – JWT token for authentication

  • onMessage: (message: string) => void – Callback for received messages

  • style?: ViewStyle – Custom styles for the container


✨ Features

  • Expo compatibility

  • Audio permission handling

  • Mute/unmute functionality

  • Real-time message handling

  • Customizable styling

  • TypeScript support


⚑ Requirements

  • React Native v0.73.2 or higher

  • Expo SDK 50 or higher

  • iOS 13.0+

  • Android 5.0+

Last updated