Skip to main content
This example shows how to sign in, create an ambient session, and record in one component. First sign in. Then create a session with an encounterId. Then start recording. Use sessionStatus for the session lifecycle, such as created or submitted.
Do not use sessionStatus for recording versus paused. Keep a local phase value for your start, pause, and resume buttons.

Code example

React

Key implementation details

Use useAuth to sign in. With autoRegister: true and loginOnMount: true, sign-in runs on mount. Pass providerName, providerOrgId, and providerSpecialty when auto-registration is on. Prefer specialty enum tokens such as FAMILY_MEDICINE. See Authentication hook.
Call session.create({ encounterId }) only after the user is signed in. encounterId is required. Wait for isSuccess before you use ambientSessionId. See Create ambient session.
Pass ambientSessionId into useAmbientSession. Use start, pause, resume, and submit. Use sessionStatus for lifecycle state, and a local phase for recording versus paused. See Manage ambient session.
Always wait for isSuccess before you use ambientSessionId. An undefined session id breaks useAmbientSession.

Next steps

Refer to the Manage ambient session guide to add session context and improve note quality.
Last modified on August 13, 2026