This guide walks you through setting up the Suki Headless Web SDK in your React application, from installation to creating your first ambient recording session.
The first step is to authenticate users using the useAuth hook. This hook manages user identity and provides access tokens needed for all SDK operations.
React
Copy
Ask AI
import { useAuth } from '@suki-sdk/platform-react';function App() { const { isLoggedIn, isPending, error, login } = useAuth({ partnerId: 'your-partner-id', // Required: Replace with your actual partner ID partnerToken: 'your-partner-token', // Required: Replace with your actual partner token autoRegister: true, // Optional: Automatically register users if they don't exist loginOnMount: true, // Optional: Sign in automatically when component mounts providerName: 'Dr. John Doe', // Required for auto-registration providerOrgId: 'org-123', // Required for auto-registration providerSpecialty: 'Cardiology' // Required for auto-registration }); if (isPending) { return <div>Signing in...</div>; } if (error) { return <div>Error: {error.message}</div>; } if (!isLoggedIn) { return <button onClick={login}>Sign In</button>; } return <div>Ready to use Suki Headless Web SDK</div>;}
If you set autoRegister: true, you must provide providerName, providerOrgId, and providerSpecialty. If you prefer manual registration, set autoRegister: false and use the registerUser method. See the Authentication Hook guide for more details.
Once authenticated, create an ambient session using the useAmbient hook. This creates a session container that you’ll use for recording.
React
Copy
Ask AI
import { useEffect } from 'react';import { useAmbient } from '@suki-sdk/platform-react';function SessionCreator({ onSessionReady }) { const { ambientSessionId, session: { create, isPending, isSuccess, error } } = useAmbient(); // Create session when component mounts useEffect(() => { create(); }, [create]); // Pass session ID to parent when ready useEffect(() => { if (isSuccess && ambientSessionId) { onSessionReady(ambientSessionId); } }, [isSuccess, ambientSessionId, onSessionReady]); if (isPending) { return <div>Creating session...</div>; } if (error) { return <div>Error: {error.message}</div>; } return null;}
You must wait for isSuccess to be true before attempting to use the ambientSessionId. Passing an undefined ID to the recording hooks will cause errors.
Use the useAmbientSession hook to control recording. This hook provides methods to start, pause, resume, and submit recordings, along with session status.
Always use setSessionContext to provide relevant patient or encounter details. This context acts as a hint for the AI, resulting in significantly higher quality clinical notes.