krosai-react-native-sdk

1.0.0 • Public • Published

Krosai 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

  1. Install the required dependencies:
npm install krosai-react-native-sdk react-native-webrtc expo-av expo-permissions @react-native-async-storage/async-storage
  1. 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."
        }
      ]
    ]
  }
}

Usage

Basic Usage

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 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

VoiceAssistant

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

Features

  • Expo compatibility
  • Audio permission handling
  • Mute/unmute functionality
  • Real-time message handling
  • Customizable styling
  • TypeScript support

Requirements

  • React Native 0.73.2 or higher
  • Expo SDK 50 or higher
  • iOS 13.0+ / Android 5.0+

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i krosai-react-native-sdk

Weekly Downloads

5

Version

1.0.0

License

none

Unpacked Size

17.4 kB

Total Files

9

Last publish

Collaborators

  • trymoosbu