useSuki hook provides a React-friendly way to use the Suki Web SDK from components. It exposes session state, lets you handle SDK events, and exposes ambient methods without passing a JavaScript client instance through props.
Prerequisites
useSuki must be used within a component tree wrapped by SukiProvider.
Common use cases
- Initialization: Call
initwith your configuration options. UseisInitializedto avoid redundant initialization and to gate UI logic. - Token management: Call
setPartnerTokenwhen the host application supplies a newpartnerToken. - Ambient session control: Manage the lifecycle with
startAmbient,pauseAmbient,resumeAmbient,cancelAmbient, andsubmitAmbient. - State monitoring: Read
activeAmbientId,isAmbientInProgress,isAmbientPaused, anderrorto drive UI updates or logging. - Event handling: Use
onto subscribe to SDK events (for exampleambient:updateorerror; refer to Emitter events). Like the JavaScript client, this returns an unsubscribe function same pattern asSDKClientInstance.onin Classes. - Authentication and encounter data: Use
setEncounterto push encounter context updates, andattemptLoginto trigger re-authentication same role asSDKClientInstance.attemptLoginin Classes.
useSuki hook
Usage
CalluseSuki() with no arguments from a descendant of SukiProvider.
Typescript
Returns
The hook returns aUseSukiReturn object. Its properties and methods mirror those on SDKClientInstance from the JavaScript initialize() path. The following sections document each field and method.
UseSukiReturn type
Return type of theuseSuki hook containing SDK state and methods.
JavaScript