React Native chat SDK quickstart Beta
A React Native chat package with a ready-made UI kit: conversation list, chat screen, voice notes, push registration, offline queue in AsyncStorage and call invites that open the Titli Video SDK. Beta 0.1.0, on request.
Beta 0.1.0, on request. The React Native chat SDK is not on a public Git host or package registry. To get it, open SDK downloads in the console and press Request access; after approval you download the versioned archive there, with its sha256 checksum, changelog and install steps for your App ID. You can also ask for access on WhatsApp or hello@titliapp.com. Install lines marked "after access is granted" need that archive. What was tested: emulators and macOS so far. Push notifications on real devices are not verified yet.
Set in your dashboard vs. set in code
| Setting | Where |
|---|---|
| App Key, its bindings (package name, bundle ID, website, signing certificate) and Quick-mode caps | Dashboard: Console → Projects → Quick mode |
| Chat push credentials (FCM, APNs), profanity filter, recall window | Dashboard: Console → Chat |
| Chat plan (Free, Pay as you go) | Dashboard: Console → Chat |
| Chat token lifetime | Code: Quick mode handles it for you; with server tokens, ttl_seconds (60 to 604800 seconds) |
| Who the user is (user id, display name) | Code: init / setUser in the app |
Quick mode: add your App Key, chat in 5 minutes
No backend needed: add your App Key in the app and start calling. A server is optional, for production hardening.
- Get your App Key. In the console, open Projects → Quick mode and add your app's website address, package name or bundle ID. Your App Key is shown there.
- Install the package.terminal
# the chat package from your console (SDK downloads or a Support ticket) npm install ./vendor/titli/titli-chat-0.1.0.tgz - Init with the App Key, then start or join a conversation. That is all: no server, no tokens.Chat.tsx
const chat = createTitliChat({ appKey: 'tak_…', userId: 'user-42', appId: 'com.example.app' }); // appId: your bundle ID / package name await chat.connect(); // no token: the SDK fetches and refreshes it
The App Key is publishable, not a secret: it can only reach the app-facing routes, it is bound to your package name, bundle ID or website, and spend and usage caps fence it. The binding is a deterrent, not a lock (a determined attacker can copy an app's identity), so the caps are what limit the damage. For strict control, add server tokens (production hardening below). Quick mode: bindings, caps and error codes · Read the Client API (Quick mode).
That is the whole setup: connect() with no token asks for the chat token with your App Key (POST /v1/chat/client/tokens), refreshes it before it expires and whenever the server asks, and saves the user's own profile (PUT /v1/chat/client/users/{user_id}). See the Client API (Quick mode). A server is optional: it is under production hardening at the end.
The detail for React Native: install, connect and render the UI, then push and calls. React Native 0.76+ (new architecture supported, tested on 0.83), Android 7.0+ (minSdk 24), iOS 15.1+. Expo: development build only (not Expo Go).
Need React Native today, without a request? The JavaScript core @titli/chat runs on React Native with your own screens: see the chat quickstart. This page is the beta package that adds the ready-made UI kit, app-lifecycle handling and the calls bridge.
1. Install (after access is granted)
@titli/chat-react-native and @titli/chat are not on npm. Download titli-chat-react-native-0.1.0.zip from the console (SDK downloads), copy the .tgz files from it into your project (for example vendor/titli/) and install them by path:
# after access is granted
npm install ./vendor/titli/titli-chat-0.1.0.tgz ./vendor/titli/titli-chat-react-native-0.1.0.tgz \
@react-native-async-storage/async-storage react-native-svg
cd ios && pod installThe imports below (@titli/chat-react-native) are the names those files install under.
Voice notes are optional. To turn them on, also install the audio library and add the microphone text on iOS:
npm install react-native-nitro-sound@0.2.21 react-native-nitro-modules<!-- ios/<App>/Info.plist -->
<key>NSMicrophoneUsageDescription</key>
<string>Your microphone is used to record voice messages.</string>Android needs nothing else: INTERNET is already in a React Native app and RECORD_AUDIO merges in from the audio library.
2. Connect and render the UI
import { useEffect, useState } from 'react';
import { TitliChatProvider, TitliChatScreen, TitliConversationList, createTitliChat, type Conversation } from '@titli/chat-react-native';
import { createNitroVoiceAdapter } from '@titli/chat-react-native/voice-nitro'; // only if you installed the audio library
// Quick mode: your App Key and your own user id. No backend needed.
// appId: your bundle ID on iOS (required there); on Android the package name is read for you.
const chat = createTitliChat({ appKey: 'tak_…', userId: 'u_42', userName: 'Asha', appId: 'com.example.app' });
const voice = createNitroVoiceAdapter();
export function Inbox() {
const [open, setOpen] = useState<Conversation | null>(null);
useEffect(() => {
chat.connect(); // no token: fetched and refreshed with the App Key
return () => chat.disconnect();
}, []);
return (
<TitliChatProvider client={chat}>
{open
? <TitliChatScreen conversation={open} onBack={() => setOpen(null)} voice={voice} />
: <TitliConversationList onSelect={setOpen} />}
</TitliChatProvider>
);
}That is the whole inbox: conversation list (unread, presence, typing) and chat screen (text, images, files, voice notes, reactions, replies, edit, unsend, ticks, history paging) in light and dark. Start a chat with const conv = await chat.openDirect('u_99'). Messages typed offline are stored in AsyncStorage and sent once when the connection returns, even after the app was killed. The socket closes a few seconds after the app goes to the background (push takes over) and reconnects on return.
Theme and texts: theme={{ appearance: 'auto', accent: '#0EA5E9' }} and strings={{ messageHint: 'Write a message' }} on any component. Attachments: pass onAttach={async () => ({ uri, name, type })} and open your picker inside it.
Push notifications
Push on real phones is not verified yet. The code below is what the SDK provides; treat it as beta and tell us what you see.
Register the device token after login; parse incoming pushes with one function.
import { Platform } from 'react-native';
import messaging from '@react-native-firebase/messaging'; // your own push library; the SDK does not depend on it
import { parseChatPush, usePushRegistration } from '@titli/chat-react-native';
// Inside a component, once you have the FCM (Android) or APNs (iOS) token:
usePushRegistration(chat, token ? { platform: Platform.OS === 'ios' ? 'apns' : 'fcm', token } : null);
messaging().setBackgroundMessageHandler(async (msg) => {
const push = parseChatPush(msg.data); // null when it is not a Titli Chat push
if (push?.kind === 'message') showNotification(push.title, push.body, { cid: push.cid });
});Upload your FCM service account and APNs key in the console (Chat → Push). Push is sent only while the user has no live socket, so the app shows nothing twice.
Calls (with the Titli Video SDK)
The chat header has voice and video call buttons, and a call.invite (or a kind=call_invite push) rings in the app. Install the Titli Video SDK for React Native (0.2.0 or newer) and wrap the app once. Because the chat was made with your App Key, leave out getCallCredentials: Accept gets the Video SDK token with the App Key, and quickPrepareCall(chat) creates the call for the caller. No backend.
import { TitliChatCalls, useTitliCalls, quickPrepareCall } from '@titli/chat-react-native/calls';
// Quick mode: no getCallCredentials
<TitliChatCalls client={chat}>
<App />
</TitliChatCalls>
// Inside it, the chat screen: create the call, ring, join on accept
const calls = useTitliCalls();
<TitliChatScreen
conversation={open}
prepareCall={quickPrepareCall(chat)}
onCall={(c) => calls.joinCall(String(c.data.call_id), { audioOnly: c.type === 'audio' })}
/>The Video SDK package is on npm: npm install titli-video-sdk-react-native @livekit/react-native @livekit/react-native-webrtc livekit-client. The same package is also in this archive, as a fallback.
Calls from a push while the app was closed: calls.presentPush(remoteMessage.data) shows the banner. In 0.1.0 the server's call push does not carry the call_id (only the live call.invite event does), so call.callId is null for a call that came from a push and getCallCredentials cannot fetch a token for it yet; calls ring and connect normally while the app holds a connection.
Production hardening (optional): server tokens
You do not need a server to start: Quick mode works with the App Key alone. Add a server when you want strict control over every call (who joins which call, for how long, in which role): keep the project key on your server and mint a short-lived join token per person there. The app uses the same SDK and hands it a token instead of the App Key. Both ways can run side by side.
Chat token from your server
Your server keeps the API key and mints a short-lived token for the signed-in user (any language works; Node shown). user_id is your own user id: 1 to 128 characters from A-Z a-z 0-9 _ . : @ -.
// Your server (Node 20+), optional: production hardening. The API key stays here, never in the app.
app.post('/titli/chat-token', async (req, res) => {
const r = await fetch('https://api-videosdk.titliapp.com/v1/chat/tokens', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Basic ' + Buffer.from(process.env.TITLI_KEY_ID + ':' + process.env.TITLI_KEY_SECRET).toString('base64'),
},
// req.user is YOUR signed-in user (from your own session), never taken from the request body
body: JSON.stringify({ user_id: req.user.id, name: req.user.name, ttl_seconds: 3600 }),
});
if (!r.ok) return res.status(502).json({ error: await r.text() });
res.json({ token: (await r.json()).token });
});In the app:
async function fetchChatToken(): Promise<string> {
const res = await fetch('https://your-server.example/titli/chat-token', { method: 'POST', headers: { Authorization: 'Bearer ' + session } });
return (await res.json()).token;
}// Same SDK, Secure mode: the token comes from your server
const chat = createTitliChat({ apiUrl: 'https://api-videosdk.titliapp.com' });
fetchChatToken().then((token) => chat.connect(token, { tokenProvider: fetchChatToken }));Calls with server tokens
Pass getCallCredentials; your server creates the call and the tokens as in the video quickstart (production hardening there):
import { TitliChatCalls, useTitliCalls } from '@titli/chat-react-native/calls';
<TitliChatCalls client={chat} getCallCredentials={async (call) => {
const { token, livekit_url } = await myServer.callToken(call.callId); // POST /v1/calls/{id}/tokens on your server
return { url: livekit_url, token };
}}>
<App />
</TitliChatCalls>Incoming: the banner shows, Accept sends call.accept, asks getCallCredentials and opens TitliCallScreen. Outgoing: create the call on your server before the invitation and join when the other side accepts:
const calls = useTitliCalls();
<TitliChatScreen
conversation={open}
prepareCall={async (type) => ({ call_id: (await myServer.createCall(type)).call_id })}
onCall={async (c) => {
const { token, livekit_url } = await myServer.callToken(String(c.data.call_id));
calls.join({ url: livekit_url, token, title: c.conversation?.name ?? '', audioOnly: c.type === 'audio' });
}}
/>Known gaps in 0.1.0
- No public package mirror: access is requested in the console (see the note at the top).
- Push on real devices is not verified yet. Testing so far was on emulators and on macOS.
- Calls from a push: the server's call push has no
call_idand iOS gets a normal alert, not a VoIP push. A closed app shows the ring or notification but cannot join from it; ringing and joining work while the app is connected. - Attachments that were still uploading are not kept across an app restart (text and uploaded attachments are).
- Group chats show "sent" ticks only; per-member receipts are events in the core, not drawn by the UI kit.
- No search screen and no mentions picker in the UI kit (the core APIs exist).
Next
- The README inside the package you receive covers the core API, hooks, theme tokens and the
VoiceAdapterinterface. - An example app ships in the package (
example). - Chat API reference: REST endpoints, WebSocket operations, events, errors and webhooks.
- Chat quickstart for the web, the React UI kit and Flutter, which are available today without a request.