Upgrading from 0.1
If you’re on 0.1.x and upgrading, here’s what to know. If you’re starting fresh, skip this page.
The short version
Section titled “The short version”useSendMessageworks differently. You pass the thread ID when you call it, not when you mount the hook.- You don’t need
useThinkworkMeanymore. The SDK handles the fallback internally for Google‑federated users. - You can create a thread and send its first message in one call now.
- Unread counts come from the server — you no longer have to scan the thread list yourself.
- The package lives on public npm. No more vendored tarballs.
Everything else mostly just works. Here are the specific swaps you’ll need to make.
useSendMessage is now unbound
Section titled “useSendMessage is now unbound”The old version took the thread ID at hook time. The new one takes it at call time. This matters because it means you can send to a thread you just created, without a re‑render in between.
Before:
const send = useSendMessage(threadId);await send(text);After:
const sendMessage = useSendMessage();await sendMessage(threadId, text);If you want to stamp senderId for attribution, pass it as an option:
await sendMessage(threadId, text, { senderId: currentUser.id });useThinkworkMe is gone
Section titled “useThinkworkMe is gone”useThinkworkAuth().user.tenantId is now always populated once the user is signed in — even for Google accounts that previously needed the me workaround. Delete any host‑side useThinkworkMe helper and replace its callers:
Before:
const { tenantId } = useThinkworkMe();After:
const { user } = useThinkworkAuth();const tenantId = user?.tenantId;One call to create a thread and its first message
Section titled “One call to create a thread and its first message”The old two‑step pattern went away. Pass firstMessage on createThread:
Before:
const thread = await createThread({ tenantId, agentId, title, channel: "CHAT" });await sendMessage(thread.id, text);After:
const thread = await createThread({ tenantId, agentId, title, channel: "CHAT", firstMessage: text,});The backend creates both in one transaction, so there’s no orphan‑thread risk if the message fails.
Unread counts come from the server
Section titled “Unread counts come from the server”If you were fetching threads just to count them:
Before:
// Your own query + client-side counting logicconst count = countUnread(threads);After:
const { count } = useUnreadThreadCount({ tenantId, agentId });New hooks you might want
Section titled “New hooks you might want”useAgents— agent list (was likely a host‑side helper before).useThreads— thread list with filters; replaces rawuseQuery(ThreadsQuery).useUpdateThread— unbound likeuseSendMessage, for marking read / archiving / changing status.useThreadUpdatedSubscriptionanduseThreadTurnUpdatedSubscription— tenant‑wide streams.
Installing from npm
Section titled “Installing from npm”Drop the vendored tarball and switch to the published package:
{ "dependencies": { "@thinkwork/react-native-sdk": "^0.2.0-beta.2" }}The beta dist‑tag tracks the latest pre‑release. When 1.0 ships, latest will point at stable.
What’s next
Section titled “What’s next”0.3.0 is going to change how the SDK gets its config — instead of build‑time env vars, config will sync down from a Company Settings panel at runtime. Your code doesn’t have to change; you just pass the config to ThinkworkProvider from whatever source you want. More on that when 0.3.0 ships.