Hooks

useSuki

React hook for managing SDK state and operations within React components.

const client: UseSukiReturn = useSuki();

Returns

UseSukiReturn - Object containing SDK state and methods for ambient session management.

Types

UseSukiReturn

Return type of the useSuki hook containing SDK state and methods.

type UseSukiReturn = {
  activeAmbientId: string | null;
  attemptLogin: () => void;
  cancelAmbient: () => void;
  error: SukiError | null;
  init: (options: ReactInitOptions) => void;
  isAmbientInProgress: boolean;
  isAmbientPaused: boolean;
  isInitialized: boolean;
  on: <T extends keyof EmitterEvents>(
    type: T,
    handler: (args: EmitterEvents[T]) => void | Promise<void>,
  ) => () => void;
  pauseAmbient: () => void;
  resumeAmbient: () => void;
  setEncounter: (encounter: Encounter) => Promise<void>;
  setPartnerToken: (partnerToken: string) => void;
  startAmbient: () => void;
  submitAmbient: () => void;
};

Properties

PropertyTypeDescription
activeAmbientIdstring | nullThe ID of the currently active ambient session, or null if no session is active
errorSukiError | nullCurrent error state of the SDK, or null if no errors
isAmbientInProgressbooleanWhether an ambient session is currently in progress
isAmbientPausedbooleanWhether the current ambient session is paused
isInitializedbooleanWhether the SDK has been successfully initialized

Methods

MethodParametersReturn TypeDescription
attemptLogin-voidAttempts to authenticate when SDK is not authenticated after initialization
cancelAmbient-voidCancels the current ambient session
initoptions: InitOptionsvoidInitializes the SDK with the provided options
ontype: T, handler: Function() => voidSubscribes to SDK events. Returns an unsubscribe function
pauseAmbient-voidPauses the current ambient session
resumeAmbient-voidResumes a paused ambient session
setEncounterencounter: EncounterPromise<void>Updates the current encounter data
setPartnerTokenpartnerToken: stringvoidUpdates the partner token after token refresh
startAmbient-voidStarts a new ambient session
submitAmbient-voidSubmits the current ambient session