Hook Guide
Each hook is one job. Pick the one that matches what you’re building; the SDK hides the plumbing.
For the full signatures, return shapes, and cache semantics, see the package README.
Who’s signed in
Section titled “Who’s signed in”useThinkworkAuth
Section titled “useThinkworkAuth”Tells you whether someone’s signed in and gives you a way to sign them in or out. You’ll use this early — probably at your app root, to gate screens behind authentication.
Agents
Section titled “Agents”useAgents
Section titled “useAgents”Gives you the list of agents a tenant has. Use this to build an agent picker. The SDK intentionally stays out of selection state — you decide how the user chooses one, and where you store their choice.
Threads
Section titled “Threads”useThreads
Section titled “useThreads”The thread list for a tenant, optionally filtered by agent, status, priority, type, and a few others. Most list screens call this one.
useThread
Section titled “useThread”A single thread by ID. Use it when you’re rendering a thread detail view and need the title, status, or other metadata.
useUnreadThreadCount
Section titled “useUnreadThreadCount”A number: how many threads have new activity the user hasn’t seen. Use this to drive tab‑bar badges or notification dots without scanning threads yourself.
useCreateThread
Section titled “useCreateThread”Make a new thread. Pass a firstMessage and the thread + opening user message get created in one round trip — no need to create then send.
useUpdateThread
Section titled “useUpdateThread”Change something on a thread: mark it read, archive it, change its status. Works for any thread ID — you pass it when you call the function, not when the hook mounts.
Messages
Section titled “Messages”useMessages
Section titled “useMessages”All the messages in a thread. Auto‑updates when new ones arrive; you don’t wire subscriptions yourself.
useSendMessage
Section titled “useSendMessage”Send a message to a thread. You pass the thread ID at send time, so the same hook works for brand‑new threads and ones that have been mounted forever.
Real‑time
Section titled “Real‑time”The SDK subscribes for you automatically inside useMessages, but sometimes you want to listen outside a messages list.
useNewMessageSubscription
Section titled “useNewMessageSubscription”Fires when a new message lands on a specific thread. Handy for notifications or typing indicators.
useThreadUpdatedSubscription
Section titled “useThreadUpdatedSubscription”Tenant‑wide stream — fires whenever any thread’s status or title changes. Useful for dashboards.
useThreadTurnSubscription / useThreadTurnUpdatedSubscription
Section titled “useThreadTurnSubscription / useThreadTurnUpdatedSubscription”Agent turn progress — “is the agent still thinking?”. The first is scoped to one thread; the second is tenant‑wide.
Types to import
Section titled “Types to import”All the data shapes (Thread, Agent, Message, CreateThreadInput, etc.) re‑export from the package root, so you can type your own components against them without digging.
import type { Thread, Agent, Message } from "@thinkwork/react-native-sdk";