The browser SDK

Beta

Everything the widget does, as functions — so the interface is yours.

WarningNot on npm yet

The package is built and the surface below is the one it has — this section was written before it existed and has been kept true to it since. What is still missing is the publish: there is nothing to 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 widgetOne script tag. Looks like Tigerbase, configured from your dashboard. Nothing to build.
@tigerbase/clientFunctions. You build the interface; the dashboard still decides what the agent is.
@tigerbase/serverA 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:

chat.ts
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.

Your interface talks to the SDK. The SDK talks to the same API the widget uses.

NoteWhich is why there is no component to import

A rendered component would be a second widget, and you would spend your time fighting it to change a colour. What you get instead is the part that is genuinely hard: reading a streamed answer whose frames arrive split across network reads, keeping a visitor’s identity, mapping every refusal to a code you can branch on, and falling back to 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.
idThe visitor id this conversation is using.

Also exported

TigerbaseErrorThe 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 · contrastRatioThe 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 · parseFrameThe stream reader on its own, for a caller with their own transport.
createTypingSignal · TYPING_EXPIRY_MSThe typing timing rules on their own.

TipStart with the complete example

If you learn faster from a working file than from a reference, the complete example is one React component using every call above. Come back here when you want to know why a line is there.

The section

Read in order the first time; after that it is a reference.

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.