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-storageFor 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 URLtoken: stringβ JWT token for authenticationonConnected?: () => voidβ Callback when successfully connectedonDisconnected?: () => voidβ Callback when disconnectedonError?: (error: Error) => voidβ Callback for connection errorsstyle?: ViewStyleβ Custom styles for the container
π£οΈ VoiceAssistant
A higher-level component that adds voice assistant functionality.
Props:
url: stringβ Krosai WebSocket server URLtoken: stringβ JWT token for authenticationonMessage: (message: string) => voidβ Callback for received messagesstyle?: 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