React
BaseeraProvider, the hooks, and how the React package fits with the UI kit.
@baseera/react connects your React app to a Baseera agent. It holds the session, the messages, the tool loop and the approvals, and exposes them as hooks. It draws nothing itself: the ready-made interface lives in @baseera/ui.
It works in React 18 and 19, in the Next.js App Router and in Vite. Nothing touches window during render, so server rendering is safe. The session id lives in sessionStorage when it is available, so a reload resumes the conversation.
import { BaseeraProvider, useBaseeraChat, useBaseeraTool } from "@baseera/react";What is in the package
| Export | Purpose |
|---|---|
BaseeraProvider | Creates the client and the chat for everything under it. |
useBaseeraChat | Messages, status, send, stop, approve, reject, undo. |
useBaseeraTool, useBaseeraToolDefinition | Register a tool the assistant can call. |
useBaseeraContext | Tell the assistant where the user is. |
useBaseeraApprovals | Build your own approval interface. |
useBaseeraFeedback | Thumbs up and down on replies. |
useBaseeraKnowledgeUpload | Let a tenant's admins upload documents. |
useBaseeraImmersive, useBaseeraImmersiveState, useBaseeraSignal, useBaseeraField | Immersive mode for the record a user works in. |
useBaseeraTheme, useBaseeraAgentTheme | Read the theme. |
Every hook must run inside BaseeraProvider. Outside it they throw.
Two ways to build the interface
Use the surface
Render BaseeraSurface from @baseera/ui/connected. You get the launcher, the panel, sources, approvals and error text.
Draw your own
Use useBaseeraChat and useBaseeraApprovals, and render what you like.