1. Ethora
  2. Docs
  3. React Native

Add chat to a React Native app

@ethora/chat-component-rn gives an iOS and Android app a full chat UI (room list, rooms, history, media, push) in one <Chat> component. This guide installs it, connects it to Ethora Cloud and signs your existing users in without a second login.

Watch

Prefer to watch? The whole integration in under 3 minutes

Using Claude Code or Codex?

Let Claude Code or Codex do it

Our open-source skill for Claude Code and Codex runs the steps on this page for you: it installs the SDK, signs in to Ethora from your terminal to create or pick an app, writes the env files and, with your OK, adds the sign-in token route to your backend. Then it checks the setup.

/plugin marketplace add dappros/chat-ethora-skill
/plugin install ethora-skill@ethora

Then ask your agent to add Ethora chat to this app. Cursor and other agents: npx skills add dappros/chat-ethora-skill.

Prerequisites

  • React 18 or later and React Native 0.73 or later. The SDK is tested on Expo SDK 53–57 with the New Architecture on; its own toolchain runs Expo SDK 57, React Native 0.86 and React 19.2.
  • Node.js 18 or later.
  • A development build. Expo Go cannot run this SDK (it ships fixed native versions; you get a [Worklets] Mismatch… error). The first npx expo run:ios|android takes 5–10 minutes; then npx expo start --dev-client is enough.
  • An Ethora app: sign up at app.chat.ethora.com/register for an appId and app token. Your backend also needs the app secret (admin panel → app → Settings → API).

Install

Order matters. If you run npm install @ethora/chat-component-rn first, npm auto-installs the SDK's optional peers and fails with ERESOLVE, or pulls native packages newer than your Expo SDK supports. Install the peers with npx expo install first.

Expo

bash
# 1. Required native peers (versions matched to your Expo SDK)
npx expo install react-native-reanimated react-native-worklets react-native-gesture-handler react-native-svg \
  @react-native-async-storage/async-storage @react-native-community/netinfo react-native-get-random-values \
  react-native-safe-area-context
# 2. Media peers (optional, but needed for images, video, files and audio)
npx expo install expo-audio expo-asset expo-video expo-clipboard expo-document-picker expo-image-manipulator \
  expo-image-picker expo-media-library expo-file-system expo-font expo-secure-store expo-blur expo-haptics
# 3. The SDK, without npm's peer auto-install (uuid: the SDK imports it but 26.11.x doesn't list it)
npm install @ethora/chat-component-rn@latest uuid --legacy-peer-deps
# 4. Both must be clean
npx expo-doctor
npx expo install --check
# 5. Development build, then Metro with a cleared cache
npx expo run:ios        # or: npx expo run:android
npx expo start --dev-client -c
  • Skip react-native-worklets on Reanimated 3; it is only for Reanimated 4+ (Expo SDK 54+).
  • If a later npx expo install also fails with ERESOLVE, add legacy-peer-deps=true to .npmrc.
  • Optional: npx expo install react-native-mmkv for a faster encrypted cache.

Bare React Native

Run npx install-expo-modules@latest first, or leave out the expo-* packages (pickers and playback then do nothing). Then run steps 1–3 above and build natively:

bash
cd ios && pod install && cd ..
npx react-native run-ios        # or: npx react-native run-android
npx react-native start --reset-cache

Restart Metro with a cleared cache after installing peers. A Metro left running during the install serves old transforms and shows the Worklets mismatch error even in a correct build.

Babel and app entry

  • Expo: no babel.config.js change. babel-preset-expo adds the Reanimated/Worklets plugin.
  • Bare RN: if the app crashes at start after install, the Reanimated Babel plugin is missing. Add it as Reanimated's install guide describes, then rebuild.
  • No Metro shim is needed.

Import react-native-gesture-handler first in your entry file and wrap the root in GestureHandlerRootView:

tsx
// app/_layout.tsx (Expo Router) — in bare RN, do the same in index.js / App.tsx
import 'react-native-gesture-handler';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { Stack } from 'expo-router';

export default function RootLayout() {
  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <Stack />
    </GestureHandlerRootView>
  );
}

Configure for Ethora Cloud

React Native differs from the web SDK in one place: xmppSettings.devServer is a bare host. The SDK builds wss://<host>/ws itself.

ethora.config.ts
import type { ComponentProps } from 'react';
import type { Chat } from '@ethora/chat-component-rn';

type ChatConfig = NonNullable<ComponentProps<typeof Chat>['config']>;

export function buildEthoraConfig(clientJwt: string): ChatConfig {
  return {
    appId: process.env.EXPO_PUBLIC_ETHORA_APP_ID ?? '',
    customAppToken: process.env.EXPO_PUBLIC_ETHORA_APP_TOKEN ?? '', // "JWT eyJ…", keep the prefix
    baseUrl: 'https://api.chat.ethora.com',
    xmppSettings: {
      devServer: 'xmpp.chat.ethora.com', // bare host, not wss://…/ws
      host: 'xmpp.chat.ethora.com',
      conference: 'conference.xmpp.chat.ethora.com',
    },
    initBeforeLoad: true,
    newArch: true,
    refreshTokens: { enabled: true },
    jwtLogin: { enabled: true, token: clientJwt },
  };
}

In bare RN, use literals or react-native-config instead of EXPO_PUBLIC_*. Never put the app secret in the app.

Add the chat screen

EthoraChatScreen.tsx
import React, { useEffect, useMemo, useState } from 'react';
import { ActivityIndicator, Text } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { Chat } from '@ethora/chat-component-rn';
import { buildEthoraConfig } from './ethora.config';

// Absolute URL: on a device, "localhost" is the phone.
const TOKEN_ENDPOINT = 'https://your-backend.example.com/api/ethora/token';

type Props = { sessionToken?: string | null; roomJID?: string; isVisible?: boolean };

export default function EthoraChatScreen({ sessionToken, roomJID, isVisible }: Props) {
  const [token, setToken] = useState<string | null>(null);
  const [error, setError] = useState<string | null>(null);

  useEffect(() => {
    fetch(TOKEN_ENDPOINT, { headers: sessionToken ? { Authorization: `Bearer ${sessionToken}` } : {} })
      .then(async (r) => { if (!r.ok) throw new Error(`${r.status}`); return r.json(); })
      .then((d: { token: string }) => setToken(d.token))
      .catch((e) => setError(String(e.message || e)));
  }, [sessionToken]);

  const config = useMemo(() => (token ? buildEthoraConfig(token) : null), [token]);

  if (error) return <Text>Chat is unavailable: {error}</Text>;
  if (!config) return <ActivityIndicator style={{ flex: 1 }} />;

  return (
    <SafeAreaView style={{ flex: 1 }} edges={['top']}>
      <Chat config={config} roomJID={roomJID} isVisible={isVisible} />
    </SafeAreaView>
  );
}
  • Do not wrap <Chat> in your own XmppProvider. <Chat> mounts its own redux store and XmppProvider. An outer provider crashes 26.9.x with could not find react-redux context value. This is the opposite of the web SDK.
  • Render <Chat> only once the token exists. If it mounts with an empty token, the Ethora login screen appears.
  • Omit roomJID to show the room list. Pass it to open a single room.

Sign users in with jwtLogin

Your backend signs a short-lived HS256 JWT with the app secret (data.type: "client", your appId, your stable userId) and returns it from GET /api/ethora/token as { "token": "<jwt>" }. The SDK exchanges it at POST /v1/users/client. That endpoint does not create users: sync each user first with POST /v1/users/batch, or it answers 401 USER_NOT_FOUND. See Authentication for the backend route.

When your app signs out, call await logoutService.performLogout() (or await useLogout()()) before you clear your own session. Otherwise the next user can see the previous user's chats.

Expo Router vs React Navigation

  • Expo Router: put the screen at app/chat.tsx or app/(tabs)/chat.tsx and render EthoraChatScreen with the session from your auth context. On Expo SDK 56+, app code must not import from @react-navigation/*. Take useIsFocused from expo-router and other helpers from expo-router/react-navigation.
  • React Navigation: <Stack.Screen name="Chat" component={EthoraChatScreen} />.
  • Tabs kept mounted while hidden: pass isVisible={useIsFocused()} so unread counts stay correct.
  • The chat has its own header. Hide the navigator header, or keep edges={['top']} on the SafeAreaView.

Push notifications (optional)

The SDK does not create push tokens. Get one with expo-notifications or @react-native-firebase/messaging, then return it from config.pushNotifications.getPushTokens or call registerPushToken(token). Pass a tapped notification's data to handlePushPayload(data). Upload your APNs key or Firebase service account in the admin panel → app → Settings → Push. For image previews and encrypted pushes on iOS, add "plugins": ["@ethora/chat-component-rn"] to app.json and run npx expo prebuild.

Troubleshooting

SymptomFix
[Worklets] Mismatch between JavaScript code version and Worklets Babel plugin versionUse a development build, not Expo Go. Stop Metro, run npx expo start --dev-client -c, and check npm ls react-native-worklets shows one copy.
could not find react-redux context value (stack: VideoCallOverlay → XmppProvider)Remove your outer XmppProvider.
Unable to resolve module uuid (Metro, often only in a Release build)Run npm install uuid. The SDK imports it but version 26.11.x does not declare it as a dependency.
npm install @ethora/chat-component-rn → ERESOLVEInstall peers with npx expo install first, then the SDK with --legacy-peer-deps.
As of SDK 56, expo-router is no longer compatible with react-navigationReplace @react-navigation/* imports with expo-router / expo-router/react-navigation.
/v1/users/client → 401 USER_NOT_FOUNDCreate the user with POST /v1/users/batch before minting their token.

Next steps

  • Customization: theme, dark mode, header and feature flags.
  • Authentication: the token route on your backend.
  • Rooms: create rooms server-side and open one with roomJID.

Stuck or planning something bigger?

Book 15 minutes with the team, or open an issue on GitHub. Self-hosting and enterprise questions are welcome.