The browser SDK
BetaEverything the widget does, as functions — so the interface is yours.
WarningNot on npm yet
npm install today.The same product, at two levels of commitment
Paste a script tag and you have a working chat on your site in a minute. That path does not change and most people should take it.
The SDK is for when the default look is not the point — when the chat belongs inside your own layout, your own design system, or an interface that is not a chat bubble at all. You give up nothing server-side: the same key, the same dashboard settings, the same limits.
| The widget | One script tag. Looks like Tigerbase, configured from your dashboard. Nothing to build. |
|---|---|
| @tigerbase/client | Functions. You build the interface; the dashboard still decides what the agent is. |
| @tigerbase/server | A secret key on your own server, for reading the account. A different package because it is a different level of trust — see Setup. |
| tigerbase (Dart) | The same idea for Flutter and Dart. A smaller surface — see the Dart & Flutter SDK. |
What it actually looks like
Harbor & Pine sells furniture online. Their agent knows the catalogue, the delivery areas and the returns policy. This is the whole of what their own chat panel needs from Tigerbase:
import { Tigerbase } from "@tigerbase/client";
const tigerbase = new Tigerbase({ key: process.env.NEXT_PUBLIC_TIGERBASE_KEY! });
// Everything configured in the dashboard: name, greeting, colours…
const agent = await tigerbase.config();
// A conversation that remembers who this visitor is across reloads
const chat = tigerbase.conversation();
for await (const event of chat.ask("Do you deliver to Leeds?")) {
if (event.text) render(event.text);
}Three calls: read the settings, open a conversation, ask. Everything else in this section is detail on one of those three.
Where the line is
The SDK returns data and events. It never returns markup. Anything that decides how it looks is yours; anything that decides how it talks is ours.
NoteWhich is why there is no component to import
XMLHttpRequest on runtimes whose fetch cannot stream.The whole surface
Small on purpose. If you can read this table you know everything the package can do.
On the client
| new Tigerbase({ key, apiUrl? }) | Throws at once on an empty key or a tb_live_ server key. |
|---|---|
| config() | Promise<AgentConfig> — the dashboard's settings, flat. Cached. |
| theme() | Promise<Theme> — those colours as CSS custom properties, with readable foregrounds computed. |
| conversation({ id? }) | Conversation — one visitor's thread. |
On a conversation
| ask(question, { signal? }) | AsyncGenerator<AskEvent> — the answer as it is written. |
|---|---|
| askOnce(question, { signal? }) | Promise<string> — the same turn, collected and trimmed. |
| confirm(confirmationId, approve, { signal? }) | AsyncGenerator<AskEvent> — the visitor's yes or no to a confirmation event, and what the agent does next. |
| rate(messageId, "up" | "down", { comment? }) | Promise<void> — a thumb on one answer. |
| requestHuman({ reason?, visitorName?, visitorEmail? }) | Promise<{ id, status, waitMinutes }> — ask for a person. |
| handoffStatus() | Promise<{ active: false } | { active: true, id, status, agentMessages }> — one HTTP check on whether a person is on the conversation. |
| on(event, listener) | Returns an unsubscribe. Events: human, message, resolved, typing, error. |
| typing.keystroke() · typing.stop() | The visitor's typing indicator, for a person watching. |
| reset() | string — a new visitor id. Nothing is deleted. |
| end() | Closes the socket and drops every listener. |
| id | The visitor id this conversation is using. |
Also exported
| TigerbaseError | The one error type. Branch on its code. |
|---|---|
| applyTheme(theme, element?) | Writes a theme's custom properties onto an element (the root by default). |
| readableOn · needsOutline · contrastRatio | The contrast rule theme() uses, for surfaces it does not know about. |
| fetchCanStream() | Whether this runtime's fetch can stream. Information only — the fallback is automatic. |
| readStream · framesFromText · parseFrame | The stream reader on its own, for a caller with their own transport. |
| createTypingSignal · TYPING_EXPIRY_MS | The typing timing rules on their own. |
TipStart with the complete example
The section
Read in order the first time; after that it is a reference.
Install, the one file to create, and which key goes where.
config() and theme() — everything the dashboard decided.
ask(), askOnce(), confirm(), the event stream, cancelling.
Who a visitor is, resuming, and starting again.
requestHuman() and the events that follow.
rate() and the typing indicator.
Every code, what it means, and whether to retry.
One React component, start to finish.
The same package, and the one thing it needs from you there.
What is not built yet
Every method in this section maps to an endpoint that exists. Three more are designed and not built — history(), clear() and delete() — and they are named on the Conversations page rather than left to be discovered. A method that always throws is worse than a method that is missing.
NoteLive handoff needs one more install
requestHuman() and handoffStatus() are plain HTTP. The live half — human, message, resolved and typing through on() — rides a socket, and the socket library is an optional peer: npm i socket.io-client. Without it you get an error event saying so, not silence. The details are on Handing to a person.