StradaWidget component that you must add to your app to use any SDK functionality, along with corresponding props and methods.
Props
Configure the React Native SDK by passing props to theStradaWidget component.
organizationId
organizationId: string; (required)
Your Strada organization ID. You can find this in the Strada dashboard.
agentId
agentId: string; (required)
The ID of the agent to load in the chat widget. You can find this in the Strada dashboard.
agentVariables
agentVariables?: Record<string, unknown>;
Variables to inject into your agent’s chat conversations. These variables are accessible to the AI agent and can be used to customize agent behavior, provide context, or personalize the conversation experience.
metadata
metadata?: Record<string, unknown>;
Use metadata to pass information about a user to Strada for attribution and analytics purposes. This data is not accessible to the AI agent during conversations. For passing data that should be available in chat conversations, use agentVariables instead.
Meta field keys should not include whitespace, emojis, or special characters.
defaultView
defaultView?: 'chat' | 'list';
Controls which view the widget shows when it opens. Defaults to 'chat'.
'chat': Opens directly to a chat conversation (new or existing)'list': Opens to the list of recent chats (requires authenticated user)
The list view requires user authentication via
getUserToken. Anonymous users will always start in chat
view.onReady
onReady?(): void;
Callback invoked when the SDK completes initialization. Useful for asynchronous widget loading scenarios.
onChatStart
onChatStart?(chatId: string): void;
Callback triggered when a new chat session starts.
onChatEnd
onChatEnd?(chatId: string): void;
Callback triggered when a chat session ends.
onMinimize
onMinimize?(): void;
Callback triggered when the widget is minimized.
hideButton
hideButton?: boolean;
Hides the default floating button when set to true, allowing you to trigger the widget through custom UI elements.
widgetUrl
widgetUrl?: string;
Specifies a custom widget URL. Unless directed by a Strada team member, you should not change this value.
Defaults to https://widget.getstrada.com.
getUserToken
getUserToken?(): Promise<string | null>;
Function that retrieves a JWT token from your backend for user authentication. Returns a token to establish a verified user identity for the chat session.
The
getUserToken function should return a Promise that resolves to a JWT token string, or null if
authentication should be skipped.Methods
All methods are called through the widget ref.open
open(options?: { agentId?: string }): void;
Opens the widget. Pass an agentId to switch agents when opening.
close
close(): void;
Closes the chat widget.
toggle
toggle(): void;
Toggles the widget between open and closed states.
setMetadata
setMetadata(data: Record<string, unknown>): void;
Updates metadata after initialization. Primarily useful when user context changes while the widget remains active.
Meta field keys should not include whitespace, emojis, or special characters.
subscribeEvent
subscribeEvent(eventKey: string, callback: (data: object, context: object) => void): number
Registers a callback for SDK events. Returns a subscription ID for later removal.
useEffect to ensure the widget is mounted and no events are missed:
| Event key | Data | Description |
|---|---|---|
strada:ready | { isLoaded: boolean } | Triggered when the widget has finished loading and is ready to use. |
strada:button:clicked | {} | Triggered when the floating button is clicked. |
strada:chat:started | { chatId: string } | Triggered when a new chat session starts. |
strada:chat:ended | { chatId: string } | Triggered when a chat session ends. |
strada:chat:minimize | {} | Triggered when the widget is minimized. |
unsubscribeEvent
unsubscribeEvent(subscriptionId: number): void;
Removes an event subscription using its subscription ID.
Type Signatures
The SDK exports the following TypeScript types.StradaWidgetProps
StradaWidgetRef
StradaEventKey
EventCallback
StradaEventData
Hook API
TheuseStradaWidget hook provides a convenient way to interact with the widget.