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
import { VoiceAssistant } from 'krosai-react-native-sdk';
const App = () => {
return (
<VoiceAssistant
url="wss://your-krosai-server.com"
token="your-jwt-token"
onMessage={(message) => {
console.log('Received message:', message);
}}
/>
);
};
📅 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