React SDK reference
The full API surface of @getuserfeedback/react — provider, 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>If the current app version supports a newly shipped feature, report that with
capabilities:
<GetUserFeedbackProviderclientOptions={{apiKey: "YOUR_API_KEY",capabilities: ["checkout.drawer"],}}><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[] | "granted" | Initial consent state. See Privacy & consent. |
disableAutoLoad | boolean | false | When true, call client.load() manually before opening flows. |
disableTelemetry | boolean | false | Disables anonymous performance telemetry. Does not affect user analytics. |
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. |
actions | ActionRegistration[] | none | Static custom actions and an optional webpage-navigation override. |
Actions (actions)
Register custom actions and optional browser URL handling through
clientOptions.actions. Definitions remain fixed for the provider's mounted
lifetime, while matching handler functions 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 endedonOpenRequested(callback)— observe persisted Flow opens before presentation and optionally suppress that attemptload()— manually start the widget whendisableAutoLoadistrueclose()— close any open flow
Use capabilities when the supported capabilities become known or change after
the widget has loaded:
import { useEffect } from "react";import { useGetUserFeedback } from "@getuserfeedback/react";function CheckoutRouteCapabilities() {const client = useGetUserFeedback();useEffect(() => {client.configure({capabilities: ["checkout.drawer", "messages.compose.v2"],});}, [client]);return null;}The widget checks for newly eligible flows after capabilities change. See Capabilities.
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.
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
open(options?)— open the flow (options includemetadata)prefetch()— load flow resources over the networkprerender()— warm up the UI before openingclose()— close the flowsetOpen(boolean)— declarative open/closeisLoading—trueafteropen()is requested while the flow is not visible yetshouldRenderContainer—truewhen usingcontainer: "custom"and the container should be in the DOMcontainerRef— ref to attach to your container element
These methods return promises, but both fire-and-forget and await are valid.
See
JavaScript SDK reference
for the execution model.
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.