Skip to main content
All hooks are client-side React hooks ('use client'). Every one must be called inside a <PersonaProvider> — they read fetchWithAuth and defaultAgentId from context. Every hook returns an object with at least isLoading and error fields.

useChat

The primary hook — manages a full chat conversation: sending messages, receiving streamed responses, thread history loading, interrupt handling (HITL and clarifications), workspace files/todos tracking, and error state.

Options

Return value

Usage patterns

Basic chat in a page:
Thread-aware chat with sidebar:
Monitoring events for analytics:
Controlling the send (e.g. adding metadata):

useThreads

Lists, creates, deletes, renames, and archives threads for the current user.

Options

Return value

Thread object shape

agentId is a bare string on create() and get() calls, but populated as a full object (including name, slug, and optionally avatar) on list() responses.

Usage pattern — thread sidebar


useFiles

Lists, uploads, downloads, and deletes user-uploaded files (the POST /files surface — distinct from the agent’s virtual workspace files tracked by useChat’s files field).

Options

Return value

File object shape

Usage pattern — upload with drag-and-drop

Important: files vs useChat’s files

This hook’s files (uploaded files via GET /files) is a completely different thing from useChat’s files (the agent’s virtual workspace files from STATE_SNAPSHOT events). They just happen to share the same name. When using both hooks together, rename one:

useMemory

Reads and writes the user’s persistent memory — files that survive across threads and sessions, managed by the agent’s memory system.

Options

Return value

Memory object shape

Usage pattern — read agent memory


useAgents

Lists available agents for the current user — useful for building an agent picker or showing which agent a conversation is directed to.

Options

Return value

Agent summary shape

Usage pattern — agent picker


useConnection

Checks the health/connectivity of your Persona backend — useful for showing a connection status indicator or for retry logic.

Options

Return value

Health info shape

Usage pattern — connection status bar


PersonaProvider

The context provider that all hooks depend on. Not a hook itself, but the setup is critical.

Props

What it does

  • Strips trailing slashes from baseUrl
  • Creates a fetchWithAuth function that:
    • Calls getAuthToken() on every request
    • Sets Authorization: Bearer <token> if a token is returned
    • Prepends baseUrl to every path
  • Stores everything in React Context — all hooks read from this context

Usage in Next.js App Router

Usage in a Next.js Route Handler (server-side)

For server-side usage where you want the SDK client directly, use @personaai/sdk instead. PersonaProvider is for client components only.