SukiAuthManager and FormFillingClient once inside useMemo, wrap your tree with FormFillingProvider, and render <FormFilling> when the clinician opens Form filling.
Prerequisites
Before you begin, confirm you have:- Packages:
@suki-sdk/form-filling-reactand@suki-sdk/core - Partner credentials:
partnerIdandpartnerTokenfrom Partner onboarding - Template IDs:
template_idUUIDs from your Suki support team forform_template_ids. - Encounter ID: pass your encounter ID as
correlation_id, refer to Configuration for more details. - Browser and layout: HTTPS, microphone access, and space for the Form filling UI (the
.suki-form-fillingcontainer needs height)
Integration pattern
Create auth and the client once per page insideuseMemo. Mount <FormFilling> only when the clinician is ready to open Form filling.
Suki Auth Manager
One
SukiAuthManager after the partner token is available.Form Filling Client
One
FormFillingClient in useMemo. Reuse it for every session on that page.FormFillingProvider
Wrap the part of your tree that renders
<FormFilling>.Conditional FormFilling
Mount
<FormFilling> only while Form filling should be open.Do not run
new FormFillingClient(...) on every render. Use useMemo with stable dependencies.Install the packages
Step 1: Style the container
React renders the hosted UI inside.suki-form-filling. Give that container explicit height, or the iframe looks blank.
CSS
Step 2: Create auth manager and client in useMemo
Create both objects once per page insideuseMemo. Optionally wire onError on the client for configuration and runtime errors.
React
Step 3: Wrap with FormFillingProvider
Pass theclient from Step 2 into FormFillingProvider. Every component that renders <FormFilling> must be a child of that provider.
React
FormFillingProvider at app root or only around the encounter screen that needs Form filling.
Step 4: Render FormFilling when the clinician opens Form filling
Use state (for exampleisFormOpen) so <FormFilling> mounts only while Form filling should be visible. When it unmounts, the SDK tears down the hosted UI.
Pass the same session fields you would pass to client.start(), except rootElement (React supplies the container):
form_template_ids: Requiredtemplate_idUUIDs from your Suki support team.correlation_id: Optional Your encounter or appointment ID. Strongly recommended so results map to the correct record.onSubmit: Required Called when structured JSON is ready after processing, not when the clinician taps submit. Receives aFormFillingResult.onReady,onCancel: OptionalonBackgroundSubmit: Optional React only. Results for a superseded session while the iframe is still open.
React
Callbacks and events
Your app needs to know when Form filling is ready, when structured results arrive, and when the clinician cancels. You can handle that in two ways. Option 1: Pass props on<FormFilling>
Use this for logic tied to one session. Props mirror client.start() callbacks:
Option 2: Listen with
client.on()
Use this for handlers that stay active across many sessions, such as logging, analytics, or a shared error handler. Register once when you create the client in useMemo:
React
form-filling:session-started, form-filling:background-submitted, and form-filling:error.
Refer to Callbacks for FormFillingResult shape and Events for every event and payload.
Starting another session
When the clinician opens Form filling again, mount<FormFilling> again (for example set isFormOpen back to true). You do not need a new FormFillingClient. Mount only one <FormFilling> at a time per client.
useFormFilling hook
InsideFormFillingProvider, use useFormFilling() to read session state and errors in sibling components:
React
Complete code example
Below is a full page example: sign-in, client setup inuseMemo, provider wiring, and a button that opens Form filling.
React
onSubmit returns structured_data.
Best practices
Troubleshooting
Blank Form Filling Area
Blank Form Filling Area
Set CSS height on
.suki-form-filling. Add CSP frame-src for https://sdk.suki.ai (production) or https://sdk.suki-stage.com (staging). Refer to Configuration and Prerequisites.Session Resets or Flickers
Session Resets or Flickers
Do not create
FormFillingClient on every render. Keep one client in useMemo and pass the same instance to FormFillingProvider.Multiple Sessions Conflict
Multiple Sessions Conflict
Mount only one
<FormFilling> at a time per client. Unmount the previous session before starting another.`SUKI_FF_001` Immediately
`SUKI_FF_001` Immediately
form_template_ids is empty, or no IDs match your partner account. Pass at least one template_id UUID from Suki support. Refer to Form filling templates.`SUKI_FF_002` Handshake Timeout
`SUKI_FF_002` Handshake Timeout
The iframe did not complete the ready handshake within 10 seconds. Check network, ad blockers, and CSP. Confirm the page uses HTTPS.
`SUKI_FF_003` Fetch Templates Failed
`SUKI_FF_003` Fetch Templates Failed
Auth failed or the wrong environment (staging vs production) while loading the template list. Retry and confirm
partnerId, partnerToken, and environment.`SUKI_FF_004` Iframe Runtime Error
`SUKI_FF_004` Iframe Runtime Error
Microphone permission denied, session start/submit failed, or form generation failed. Read
err.message, show a retry option, and confirm network access.UI Never Opens
UI Never Opens
Sign-in failed before the hosted UI loads. Verify
partnerId and partnerToken for your environment. Refer to Authentication.No `onSubmit` Callback
No `onSubmit` Callback
The clinician closed the processing screen early, or the tab closed before processing finished. Register a partner webhook for server-side delivery.
`onSubmit` Never Maps to Your Encounter
`onSubmit` Never Maps to Your Encounter
Pass your encounter ID as
correlation_id at session start so callbacks and webhooks match the correct record.Late Results After Offline Submit
Late Results After Offline Submit
Handle
onBackgroundSubmit on <FormFilling> or listen for form-filling:background-submitted on the client.Log Errors During Development
Log Errors During Development
Wire
onError on the client, useFormFilling() error, or client.on("form-filling:error", ...):React
Refer to Error handling for the full error code table.
Next steps
Basic usage example for a fuller sample withuseFormFilling
Session workflow for single-form vs multi-form behavior
Configuration for all <FormFilling> props
Javascript integration for plain JavaScript