Overview
This example shows how to build a component that handles authentication, session creation, and recording in one place. It uses three hooks:useAuth, useAmbient, and useAmbientSession. The flow runs in order: sign in first, then create a session, then record.
Code example
React
Key implementation details
Step 1: Authentication
Step 1: Authentication
Authentication: The
useAuth hook signs the user in. With autoRegister: true and loginOnMount: true, sign-in runs when the component mounts. If the user does not exist, the SDK registers them first. When using auto-registration, you must pass providerName, providerOrgId, and providerSpecialty. See the Authentication hook guide.Step 2: Session Creation
Step 2: Session Creation
Session Creation: The
useAmbient hook creates a new ambient session. Call session.create() only after the user is logged in. Wait for isSuccess to be true before using ambientSessionId. Passing undefined to useAmbientSession will cause errors. See the Create ambient session guide.Step 3: Recording
Step 3: Recording
Recording: The
useAmbientSession hook controls recording. Pass the ambientSessionId from step 2. The hook returns start, pause, resume, and submit methods. It also returns sessionStatus and sessionType so you can update your UI. See the Manage ambient session guide.