Guide

Clara Widget guide

One script tag adds the Clara voice scribe to any web page. It fills your own fields by id, emits events on window, and runs under your organization's key.

Install: one script tag

Paste the tag before </body> of the page where the clinician documents. The widget reads its configuration from the data-clara-* attributes of its own tag, draws the floating Clara button and, when a consultation starts, writes each value into the inputs of your page whose id or name matches a field of the template.

Two environments: cdn.clara.care talks to the production API (real systems, real patients, keys created in the production Platform) and cdn-dev.clara.care to the development API (testing and staging, no real patient data; development keys only). Keys of one environment do not work in the other.

HTML
<script
  src="https://cdn.clara.care/widget/latest.js"
  data-clara-api-key="PUBLISHABLE_KEY"
  data-clara-template="TEMPLATE_ID"
  data-clara-lang="en"
></script>

Attributes

AttributeValuesDescription
data-clara-api-keyYour organization's publishable key.
data-clara-templateTemplate filled in while dictating. Alias: data-clara-template-id.
data-clara-langes | enInterface language. If you set it, the user cannot change it.
data-clara-color#2a4276Primary color (hex).
data-clara-positionbottom-right | bottom-left | centerWhere the button appears. Defaults to bottom-right.
data-clara-launcher-left, data-clara-launcher-bottompxFixed position of the button.
data-clara-draggabletrue | falseLets the user drag the button. Defaults to true.
data-clara-auto-opentrueOpens the panel when the page loads.
data-clara-web-fonttrueLoads Plus Jakarta Sans from Google Fonts. Off by default (a strict CSP blocks it).
data-clara-voice-fill-modetext | livetext (default): fills in from each transcribed sentence. live: fills in while listening.
data-clara-chirp-transcripttrue | falseChirp does the transcription (on by default); false turns it off.
data-clara-link-qualitytrue | falseDiscreet latency indicator in the session header (on by default).
data-clara-enable-google-login, data-clara-google-client-idtrue | false, idSign-in with Google and its OAuth client id.
data-clara-login-branding-*enabled, label, partner-name, logo-url, logo-altYour organization's brand appears automatically from your key or loader; these override it.
data-clara-auto-unmounttrue | falseUnmounts when the iframe that injected it navigates away. Defaults to true.
data-clara-template-buildertrue | falseOffers to create a template from the form on screen. Defaults to true.
data-clara-trusted-originshttps://a.com,https://b.comOrigins on other domains the widget exchanges fill commands with (EHR iframes). Without them it only talks to your own origin.

How the widget finds your fields

Each field of the template has an htmlFieldId. When Clara extracts a value, the widget looks for an element with that id (or name) on the page: inputs, textareas, selects and checkboxes. It writes the value and dispatches the input and change events your framework listens to, so React, Vue or Angular state updates as if the person had typed. Fields inside iframes of your own origin work too; other origins need data-clara-trusted-origins.

The person keeps control: values are written into the form they are already looking at, nothing is saved by the widget, and a template can be created from the form on screen with the template builder.

React
// Every field with a stable id (or name): the htmlFieldId in your template.
<input id="reason_for_visit" value={reason} onChange={(e) => setReason(e.target.value)} />

// React Hook Form: register sets the name; Clara finds it just the same.
<textarea {...register('treatment_plan')} />

Events on window

The widget dispatches CustomEvents on window so your application can react: mark fields, lock them, show the transcript, or save the visit when the session ends. Clara Form listens to the same events to fill itself without any network.

JavaScript
window.addEventListener('clara:session-started', (e) => {
  console.log('Visit started', e.detail.analysisId);
});

window.addEventListener('clara:field-filled', (e) => {
  const { fieldName, value } = e.detail;
  // Clara has just filled fieldName
});

window.addEventListener('clara:session-stopped', (e) => {
  saveVisit(e.detail.analysisId);
});
Eventdetail
clara:session-started{ analysisId, timestamp }
clara:session-stopped{ analysisId, timestamp }
clara:field-filled{ fieldName, value, sectionKey, timestamp, analysisId?, sourceUtteranceId?, sourceText? }
clara:formdata-updated{ formData, changedField?, changedFields?, timestamp }
clara:transcript-updated{ role, content, messages: [{ id?, role, content, timestamp, speaker? }], timestamp, speakersChanged? }
clara:title-updated{ title, analysisId, timestamp }
clara:template-changed{ templateId, templateName, sections, timestamp }
clara:odontogram-updated{ fieldId, teeth, timestamp }
clara:odontogram-cleared{ fieldId, teeth, timestamp }

JavaScript API

CallDescription
ClaraWidget.destroy()Ends the visit in progress, unmounts the widget and deletes window.ClaraWidget.
ClaraWidget.fill(fieldId, value, sectionKey?)Fills a field on your page the way Clara would.
ClaraWidget.init(config)Manual start with the configuration in camelCase (apiKey, templateId, lang, position…). The script already starts on its own when it loads: do not call it on a mounted widget.
ClaraStore.getFormData()Values Clara has filled in.
ClaraStore.getTranscript()Transcript messages.
ClaraStore.getCurrentAnalysis()Active visit.
ClaraStore.isAuthenticated()Whether there is a signed-in session.
ClaraStore.subscribe(listener)Calls listener on every state change; returns the function to unsubscribe.

React and Next.js

In a React or Next.js app install @clara.care/widget and mount <ClaraWidget> once, in the layout, so it stays across routes. The component takes the same options as the attributes, in camelCase. initClaraWidget and destroyClaraWidget give you the same from plain code.

Terminal
npm install @clara.care/widget
React
'use client';
// app/clara.tsx: put it in app/layout.tsx so it stays mounted across routes
import { ClaraWidget } from '@clara.care/widget/react';

export default function Clara() {
  return <ClaraWidget apiKey="PUBLISHABLE_KEY" templateId="TEMPLATE_ID" lang="en" />;
}

Your organization: key, sites and brand

Publishable keys are created in Clara Platform, Integrate. The same screen lists your widget sites: the origins (https://your-ehr.com) where you embed Clara, which the API answers with CORS on the widget's routes and nothing else. Without that registration the browser blocks the widget's calls from your page.

Platform also gives your organization its own loader (https://cdn.clara.care/t/YOUR_CODE/widget.js) that pins a verified release and carries your name, logo and icon. With a verified custom domain the widget shows only your brand. If the organization is suspended, the API rejects its key and the widget stops working until it is reactivated.

HTML
<script
  src="https://cdn.clara.care/t/YOUR_CODE/widget.js"
  data-clara-api-key="PUBLISHABLE_KEY"
  data-clara-template="TEMPLATE_ID"
  data-clara-lang="en"
></script>

Content Security Policy and permissions

A strict CSP on your page needs these sources. The microphone is requested by the widget itself in the top-level page; if your page is served inside an iframe, delegate it with allow="microphone".

DirectiveValueFor
script-srchttps://cdn.clara.carethe widget bundle (or your organization's loader)
connect-srchttps://api.clara.caresign-in, templates, consultations
connect-srchttps://proxy-aws.clara.care wss://proxy-aws.clara.carethe voice session
connect-srchttps://*.s2.devthe consultation stream
style-src'unsafe-inline'the widget injects its stylesheet
img-srchttps://cdn.clara.careyour organization's logo and icon
Permissions-Policymicrophone=(self)recording in the top-level page

Without touching the system: the browser extension

Clinics that cannot change their software use the Clara extension for Chrome, Edge and other Chromium browsers: the same assistant from a side panel, configured with the organization's key, template and the sites where it works. Your organization's package is downloaded from Clara Platform, Integrate.

Planning an integration?

Tell us about your system and your forms. We run small pilots with technology partners.

Cookie settings

Choose which optional cookies Clara Care may use. They stay off until you turn them on, and you can change your choice at any time from Cookie settings in the footer. Privacy policy