React Native

React Native bridge over the same native chat SDKs, with the native chat screen presented from JS. RN 0.74+ (0.85+ recommended); runs on both the new TurboModule architecture and the old bridge. iOS 15.1+.

Install and quick startlink

npm install react-native-newinstance-chat
cd ios && pod install

Android needs mavenCentral() in settings.gradle.kts.

import { NewinstanceChat } from 'react-native-newinstance-chat';

const chat = new NewinstanceChat({ apiKey: 'sk_live_abc123' });
await chat.ready;
chat.setUser({ customerName: 'Ada', customerEmail: 'ada@example.com' });
await chat.initialize();
chat.openChat();

Config: { apiKey, baseUrl?, transport?: 'sse' | 'ws', initialMessage? }; user: { customerName required, customerEmail?, customerId? }. ready resolves once native configuration completes. initialize() and attachFile() return promises; setUser, openChat, closeChat, sendMessage, retryMessage and destroy return void.

Eventslink

addListener(event, handler) returns an unsubscribe function; call it on unmount. Events: messageReceived, messageSent, agentTypingChanged, connectionStateChanged (idle, connecting, connected, disconnected, offline), unreadCountChanged, error (type: network, validation, auth, system). ChatMessage carries clientId, seq, sentAt and totalMessages.

Gotchaslink

  • Handoff and typing indicators are driven by the native screen; there is no host API for them.
  • Multiple instances reconfigure the same native instance; the last configure wins. After destroy(), construct a new instance.
  • Same auth rule as every chat client: the publishable widget key ID only, never keyId:secret.