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>;
Pass data that you want to make available to your agent through agentVariables. This data can be accessible to the AI agent or be used in your actions.
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.
secureMetadata
secureMetadata?: Record<string, unknown>;
Use secureMetadata to pass sensitive data that requires an extra layer of protection. The values of secure metadata are never revealed in the UI, but they are still accessible through actions.
Use secure metadata for sensitive identifiers, tokens, or confidential information that your actions need
but should not be visible in the dashboard.
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.
modalAnimationType
modalAnimationType?: 'none' | 'slide' | 'fade';
Controls the animation used when opening the widget in the native Modal (iOS/Android). Defaults to 'none'. This has no effect on desktop, where the widget renders as an in-page view.
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.
setAgentVariables
Update agent variables. Changes take effect on nextopen() call.
setSecureMetadata
Update secure metadata (not exposed to client-side code).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.