React SDK reference
Reference for @getuserfeedback/react providers, hooks, events, and client options.
- Last reviewed
React SDK reference
The React SDK wraps the same runtime as the JavaScript SDK in a provider plus hooks. If you haven't set up yet, start with the React SDK guide.
GetUserFeedbackProvider
Initializes the widget client and makes it available to all hooks below it.
<GetUserFeedbackProvider clientOptions={{ apiKey: "YOUR_API_KEY" }}><App /></GetUserFeedbackProvider>clientOptions
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | required | Your project API key. |
colorScheme | "light" | "dark" | "system" | { autoDetectColorScheme: string[] } | auto-detect | Color scheme. See Dark mode. |
defaultConsent | "granted" | "pending" | "denied" | "revoked" | GrantScope[] | "pending" | Initial consent state. See Privacy & consent. |
disableAutoLoad | boolean | false | When true, call client.load() manually before using the widget. |
disableTelemetry | boolean | false | Disables anonymous performance telemetry. Does not affect user analytics. |
enableDebug | boolean | string | string[] | false | Enable debug logging globally or for selected namespaces. |
flags | Record<string, AppEventFlagValue> | AppEventFlag[] | none | Your app's feature flag evaluations. Used by rolling theme updates. |
capabilities | Array<string | AppEventCapability> | none | What the current app version can support. Used by capability conditions. |
links | LinksConfig | none | Synchronously route authored HTTP(S) links in the host app. |
actions | ActionsConfig | ActionRegistration[] | none | Static custom actions and the legacy browser URL override. Prefer ActionsConfig for custom actions. |
Manual loading
When disableAutoLoad is true, provide the initial color scheme, consent as
defaultConsent, and capabilities in clientOptions, then call client.load()
when you are ready to start the widget. Configure auth and make other dynamic
configuration changes after load(). A configure() call before load()
resolves without applying its update. Call load() before commands that require
the widget, such as opening a flow or tracking an event.
Links (links)
Keep clientOptions.links.router present for the provider's mounted lifetime.
Its function may change between renders, but adding or removing it after the
client initializes throws.
Actions (actions)
Register custom actions through clientOptions.actions. Definitions remain
fixed for the provider's mounted lifetime, while the handler can be refreshed. See
Actions for setup and behavior.
useGetUserFeedback()
Returns the client instance with the same core methods as the JavaScript SDK.
identify(userId, traits?, options?)— associate a user ID, traits, and optional external IDs with the current useridentify(traits, options?)— associate traits with the current useridentify(traits, undefined, options?)— three-argument form for call sites that keep options separatereset()— clear identity and auth state on logoutconfigure({ colorScheme?, consent?, auth?, capabilities? })— update settings at runtimetrack(eventName, properties?, options?)— track a product event with optional external IDspage(name?, properties?, options?)— record a browser page or web location. See Events.graph.connect(relationship)— record that two product objects are connectedgraph.disconnect(relationship)— record that the connection endedflow(flowId)— get a reusable flow handle with per-flowgetFlowState()andsubscribeFlowState(callback, options?)methodsgetFlowState()— get the instance-level aggregate flow statesubscribeFlowState(callback, options?)— subscribe to instance-level aggregate flow state; returns an unsubscribe functiononOpenRequested(callback)— observe persisted Flow opens before presentation and optionally suppress that attemptload()— manually start the widget whendisableAutoLoadistrueclose()— close any open flow
These flow observation members are inherited from the JavaScript SDK client. See
the JavaScript flow state reference
for FlowState fields, subscription options, initial emission, and abort
behavior. Client-level methods observe the aggregate state for the logical
client; the handle returned by flow(flowId) observes one flow.
See Capabilities for provider initialization and runtime update examples. The widget checks for newly eligible flows after capabilities change.
Events
Use track() for product actions and page() for browser page or web
locations. See Events for the shared argument rules
and examples.
Relationships
The client also exposes graph.connect() and graph.disconnect() for ordinary
relationship observations:
const relationship = {from: { collection: "user", id: "user_123" },to: { collection: "account", id: "acct_456" },};await client.graph.connect(relationship);await client.graph.disconnect(relationship);See Groups for audience behavior and current limitations.
useFlow(options)
The main hook for working with a specific flow. Its reactive isOpen and
isLoading values are the corresponding fields from that flow handle's
FlowState and update as the flow changes. The hook return value does not
expose width or height; use the JavaScript client or flow-handle methods
above when you need the full snapshot or an explicit subscription.
const { open, prerender, isLoading } = useFlow({flowId: "YOUR_FLOW_ID",});Options
| Option | Type | Default | Description |
|---|---|---|---|
flowId | string | required | The flow ID to target. |
prefetchOnMount | boolean | false | Prefetch flow resources when the component mounts. |
hideCloseButton | boolean | false | Hide the default close button. |
container | "default" | "custom" | "default" | Use "custom" to render inside your own element. See Containers. |
Return value
container— the selected"default"or"custom"presentation modeopen(options?)— open the flow (options includemetadata)prefetch()— load flow resources over the networkprerender()— warm up the UI before openingclose()— close the flowisOpen—truewhile the flow is visibleisLoading—trueafteropen()is requested while the flow is not visible yetshouldRenderContainer— available withcontainer: "custom";truewhen the container should be in the DOMcontainerRef— available withcontainer: "custom"; attach this ref to your container element
These methods return promises. React wraps the same JavaScript SDK runtime, so
handle a rejected command through the returned promise. Await when sequencing
matters; otherwise handle the rejection explicitly, typically with
void operation.catch(...). See
Handle command promises
for the full pattern.
Example:
const { open } = useFlow({ flowId: "YOUR_FLOW_ID" });await open({metadata: {tags: {journey_stage: "onboarding",task_type: "report-export",},},});For metadata examples and supported value shapes, see Response metadata.
useFlowContainer()
Registers one customer-owned container for flows using the default presentation
in the provider subtree, including flows opened by targeting. Mount exactly one
useFlowContainer() consumer per logical client. Providers with the same API
key and targeting context reuse that client.
| Return value | Description |
|---|---|
containerRef | Ref callback to attach to the element where flows render. |
shouldRenderContainer | true while the surrounding dialog, sheet, or panel should be visible. |
isOpen | true when a flow is visible. |
isLoading | true while an opening flow is not visible yet. |
close() | Close all open flows owned by this logical client. |
See Containers for a complete example.