React Native
The same package, and it streams out of the box. One thing still needs you.
NoteThis is not a separate package
@tigerbase/client is the package for React Native too. There is nothing else to install from us. What follows is what the runtime is missing and what to do about each.Streaming is handled for you
React Native's fetch is built on XMLHttpRequest and returns a response with no body, so the usual advice is a stack of polyfills: a streaming fetch, a ReadableStream, a TextDecoder, and a global patched before anything else imports.
You need none of them. The SDK checks once whether this runtime's fetch can stream and, where it cannot, reads the reply through XMLHttpRequest itself — whose responseText grows as the response arrives, which is the same stream by another name.
import { Tigerbase } from "@tigerbase/client";
// That is the whole setup. No polyfill, no patched global.
export const tigerbase = new Tigerbase({ key: "tb_your_key_here" });NoteYou can ask which path it took
fetchCanStream() reports whether this runtime has a streaming fetch. It is information, not something to act on — the fallback is automatic either way, and cancelling with an AbortSignal works on both.TipThe check runs before the request, on purpose
What still needs you
| The visitor id — and it fails silently | The SDK keeps one in localStorage, which React Native does not have. It falls back to a fresh id, so every launch is a new person and the agent remembers nothing. Pass your own — see below. |
|---|---|
| applyTheme — does nothing | It writes CSS custom properties onto a DOM element, and there is no DOM. Read the colours from config() and style your own components; the contrast helpers are pure arithmetic and work unchanged. |
| The domain allowlist | A native request carries no Origin header. See the warning below before you ship. |
Give the visitor a real id
Minimal
const chat = tigerbase.conversation({ id: storedVisitorId });Realistic
import AsyncStorage from "@react-native-async-storage/async-storage";
export async function visitorId(): Promise<string> {
const existing = await AsyncStorage.getItem("tigerbase.visitor");
if (existing) return existing;
const made = `rn-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
await AsyncStorage.setItem("tigerbase.visitor", made);
return made;
}
// Once, when the chat screen mounts
const chat = tigerbase.conversation({ id: await visitorId() });WarningAlways pass id on React Native
Use your own customer id instead when people sign in — opaque, 1 to 64 letters, digits or . _ : @ -. The conversation then follows them to a new phone, which a device-scoped id never does.
Colours, without applyTheme
import { readableOn } from "@tigerbase/client/contrast";
const agent = await tigerbase.config();
const brand = agent.primaryColor ?? "#dc2626";
<View style={{ backgroundColor: brand }}>
{/* Computed, not assumed: white on a pale brand is not hard to
read, it is absent — and whoever chose the colour never notices,
because they already know what the button says. */}
<Text style={{ color: readableOn(brand) }}>Ask</Text>
</View>@tigerbase/client/contrast is pure arithmetic with no DOM in it, so it works here unchanged. It is the same rule the web widget uses. readableOn returns "#000000" or "#ffffff".
Before you ship
CarefulNative requests carry no Origin, and production refuses them
The agent’s publishable key is guarded by its allowed-domains list, read from the request’s Origin or Referer. A browser always sends one; a React Native app does not. In production the public endpoints refuse a request with neither, so a release build fails with forbidden_origin (status 403, reason no_origin) while everything worked against a local backend. This is a current limitation of the platform: there is no setting today that lets a native app through.
Test against the hosted API before you ship, not only against a development server, where this check is relaxed.
All of it
- 1
Install the package
bashnpm install @tigerbase/client - 2
Pass your own visitor id
From AsyncStorage, or your own customer id. This is the one thing the SDK cannot do for you, and the one that fails quietly.
- 3
Test a release build against the hosted API
Where the missing
Originheader shows up.
If you were expecting a polyfill section, it was removed when the fallback moved into the SDK — which is where it belonged.