Skip to main content
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

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.
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.
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.
Always wait for isSuccess to be true before using ambientSessionId. Passing an undefined session ID to useAmbientSession will cause errors.

Next steps

Refer to the Manage ambient session guide to learn how to add session context and improve note quality.
Last modified on July 23, 2026