SNA

React provider and context

Props and return values for SnaProvider, SnaSession, and useSnaContext.

React provider and context

<SnaProvider>

<SnaProvider connection?: SnaConnection snaUrl?: string authToken?: string sessionId?: string hydrate?: boolean>
  {children}
</SnaProvider>
PropTypeDefaultDescription
childrenReact.ReactNoderequiredSubtree that receives SNA context.
connection{ baseUrl: string; authToken?: string }noneConnection object returned by SDK launchers. Prefer this for protected embedded SNA so the token stays paired with the URL.
snaUrlstringauto-discoverySNA internal API server URL. If omitted, it first reads the host app's /api/sna-port, then falls back to http://localhost:3099.
authTokenstringnoneToken override for custom deployments. Use it with snaUrl when the protected server is not launched by the SDK.
sessionIdstringdefaultDefault session ID for descendants.
hydratebooleantrueControls whether the chat store fetches persisted sessions and messages on mount. Set to false when the app does not use the chat store.

SnaProvider does not render UI. It provides { apiUrl, authToken, sessionId } through React context and hydrates useChatStore when requested. The discovery route may return { baseUrl, authToken } or { port, authToken }; expose it only from a trusted host app route.

<SnaSession>

<SnaSession id="review-panel">
  {children}
</SnaSession>
PropTypeRequiredDescription
idstringyesSession ID used by descendant hooks.
childrenReact.ReactNodeyesSubtree scoped to this session.

SnaSession reuses the parent API URL and changes only the session ID for the subtree.

useSnaContext()

const context = useSnaContext(): { apiUrl: string; authToken?: string; sessionId: string }
FieldDescription
apiUrlCurrent SNA server base URL.
authTokenToken used by hooks and the chat store when present.
sessionIdActive session ID for the current subtree.

On this page