ProtocolInstance methods, the useProtocol React hook, and the values they return.
Protocols drives protocol navigation — which question is current, whether the visitor can
continue, and eligibility. The question’s inputs and the visitor’s answers are owned by
Forms: render and store each answer on the form field whose
protocolFieldId the protocol reads, and the protocol reads it back. Connect a ready-made
protocol with em protocol connect.ProtocolInstance
initProtocols({ core }).initProtocol({ protocol, forms }) returns a ProtocolInstance. Every method reads the forms’ current values at call time — there is no form-data argument and no subscribe().
string
Id of the protocol’s first medical-intake question.
ProtocolQuestion | undefined
The question definition for an id, or
undefined when the id is unknown.boolean
Whether the question should be shown, given the forms’ current values.
ContinueStatus
Whether the visitor can continue past this question — see ContinueStatus.
string | null
The next visible question id, or
null at the end of the medical intake.string | null
The previous visible question id, or
null at the start.boolean
Whether the visitor has answered enough to begin the medical intake.
EligibilityResult
The eligibility outcome — see EligibilityResult.
React
Register Protocols onEmbeddablesProvider with protocols(), then drive navigation with useProtocol. Put protocols() after forms() in modules — Protocols reads the Forms client at init.
protocols()
protocols() is the module factory for EmbeddablesProvider’s modules prop — not a hook.
readonly Protocol[]
Protocol definitions to register (from
embeddables/_dist after em protocol connect).readonly string[]
Optional. Form ids whose fields protocols may read via
protocolFieldId. When omitted, every form
registered through forms() is composed in.useProtocol()
useProtocol({ protocolId }) from @embeddables/protocols/react mirrors useForm’s no-type-argument ergonomics. It owns the current question as hook-local state and recomputes derived values on every render after any composed form changes.
string
required
Id of a protocol registered through
protocols(). Throws if protocols()
was not registered or the id is unknown.For visitor or project id in React, use Core’s
useAppUserId and useEmbeddablesProjectId. For
form values and inputs, use Forms’ useForm / useFormField — Protocols reads those same forms.Result types
The two values you branch on while driving protocol navigation.ContinueStatus
Returned bygetContinueStatus(id) and the hook’s continueStatus:
EligibilityResult
Returned byisEligible() and the hook’s eligibility:
EligibilityStatus
required
qualified, qualified_for_eligible_products, disqualified, or pending.EligibilityModality
sync or async — present on qualified outcomes, omitted for disqualified / pending.string[]
required
Human-readable reasons behind the status.
string[]
Optional product ids the visitor qualifies for.
Errors
All SDK errors extendProtocolsError.

