useMemo so they are not recreated on every render), wrap your component tree with the Form filling Provider, and render FormFilling when the clinician should fill forms.
Use this approach if you are building with React and want to manage Form filling through components and hooks instead of imperative calls.
Let’s get started!
Prerequisites
Before you start:- Install
@suki-sdk/reactand@suki-sdk/core - Get your
partnerIdfrom Partner onboarding. Pass apartnerToken(JWT from your identity provider) with that Partner ID to sign in. - Decide which forms to fill: Suki Medical form templates (ask Suki support for the template IDs), your own form
schema, or both. Refer to Dynamic Form filling. - Have an encounter ID ready to pass as
correlation_id. - Run the app in a browser over HTTPS, with microphone access, and space for the Form filling UI.
Install the packages
Add the following packages to the same project you load in the browser: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
Now create the Auth Manager. You need yourpartnerId from Partner onboarding and a partnerToken (JWT from your identity provider).
In React you usually create the auth manager inside the same useMemo as the Form filling client (see Step 3), so both exist once per page or shell. The snippet below shows only the auth piece for clarity.
Code example for creating auth manager
JavaScript
Step 3: Create Form filling client
After you have created the auth manager, you can create the Form filling client for your application. The Form filling Client is the object the React components use under the hood. Create one Form filling client and reuse it for the whole tree underFormFillingProvider. Use useMemo with an empty dependency array so you do not run new FormFillingClient(...) on every render.
Code example for creating Form filling client in React
React
Step 4: Wrap with FormFillingProvider
Pass theclient from Step 3 into FormFillingProvider. Every component that renders FormFilling must be a child of that provider.
Code example for wrapping with FormFillingProvider
React
FormFillingProvider at app root or only around the screen that needs Form filling.
Step 5: Render FormFilling
RenderFormFilling only while Form filling should be open (for example when the clinician clicked “Fill Forms with Suki”). When FormFilling unmounts, the SDK tears down the hosted UI for you.
Pass forms, onSubmit, and any optional props you need. In forms, use Suki template IDs, your own schema, or both. Refer to Configuration for the full option list.
Code example for rendering FormFilling in React
React
onSubmit is required. It runs when structured JSON is ready after processing, not when the clinician taps submit in the hosted UI.Callbacks
Props such asonReady, onSubmit, and onCancel mirror the JavaScript start() callbacks. onBackgroundSubmit is React-only (results for a superseded session while the iframe is still open). You can also listen with client.on() for handlers that stay active across many sessions:
React
FormFillingResult shape and Events for every event and payload.
useFormFilling hook
InsideFormFillingProvider, use useFormFilling() to read session state and errors in sibling components:
React
Starting another session
Use the sameclient and FormFillingProvider. 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.
Unmounting
WhenFormFilling unmounts, the SDK automatically tears down the hosted UI. You do not need to call stop() yourself for normal React flows.
Complete code example
Below is a complete code example in React withFormFillingProvider, a launch button, and one Form filling session.
React
onSubmit returns structured_data, and only one FormFilling is mounted at a time for that client.
Best practices
Next steps
Configuration -forms, correlation_id, and callbacks.
Dynamic Form filling - XOR rules, schema shapes, and mixed sessions.
JavaScript integration - Integrate Form filling in a plain JavaScript application using the Suki Web SDK.