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.
- Install the required dependencies:
npm install krosai-react-native-sdk react-native-webrtc expo-av expo-permissions @react-native-async-storage/async-storage
- For Expo projects, you'll need to configure the necessary permissions in your
app.json
:
{
"expo": {
"plugins": [
[
"expo-av",
{
"microphonePermission": "Allow $(PRODUCT_NAME) to access your microphone."
}
]
]
}
}
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);
}}
/>
);
};
The base wrapper component that handles WebRTC connection and audio setup.
Props:
-
url
: Krosai server URL -
token
: JWT token for authentication -
onConnected
: Callback when connected to room -
onDisconnected
: Callback when disconnected from room -
onError
: Callback for connection errors -
style
: Custom styles for the container
A higher-level component that provides voice assistant functionality.
Props:
-
url
: Krosai server URL -
token
: JWT token for authentication -
onMessage
: Callback for received messages -
style
: Custom styles for the container
- Expo compatibility
- Audio permission handling
- Mute/unmute functionality
- Real-time message handling
- Customizable styling
- TypeScript support
- React Native 0.73.2 or higher
- Expo SDK 50 or higher
- iOS 13.0+ / Android 5.0+
Contributions are welcome! Please feel free to submit a Pull Request.
MIT