React SDK reference
The full API surface of @getuserfeedback/react — provider, hooks, 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[] | "granted" | Initial consent state. See Privacy & consent. |
disableAutoLoad | boolean | false | When true, call client.load() manually before opening surveys. |
disableTelemetry | boolean | false | Disables anonymous performance telemetry. Does not affect user analytics. |
useGetUserFeedback()
Returns the client instance with the same core methods as the JavaScript SDK.
identify(userId, traits?)oridentify(traits)— see Personalizationreset()— clear identity and auth state on logoutconfigure({ colorScheme?, consent?, auth? })— update settings at runtimeload()— manually start the widget whendisableAutoLoadistrueclose()— close any open flow
useFlow(options)
The main hook for working with a specific survey or flow.
const { open, prerender, isLoading } = useFlow({flowId: "YOUR_FLOW_ID",});Options
| Option | Type | Default | Description |
|---|---|---|---|
flowId | string | required | The flow or survey 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—truewhile the flow is loadingshouldRenderContainer—truewhen usingcontainer: "custom"and the container should be in the DOMcontainerRef— ref to attach to your container elementwidth/height— recommended dimensions for custom containers
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.
useDefaultFlowContainer()
Returns the default container ref and dimensions. Useful when you want to customize the container wrapper but keep the default sizing behavior.