React Native SDK reference
Provider props, client options, hooks, and flow controls for @getuserfeedback/react-native.
- Last reviewed
This page documents the public API for @getuserfeedback/react-native. If you
haven't set up the SDK yet, start with the
React Native SDK guide.
The React Native API uses useFlow() or client.flow(flowId) for on-demand
flows and useFlowContainer() with FlowContent for a custom native
presentation.
GetUserFeedbackProvider
Mount the provider above every component that calls useGetUserFeedback.
import { GetUserFeedbackProvider } from "@getuserfeedback/react-native";export function App() {return (<GetUserFeedbackProvider clientOptions={{ apiKey: "YOUR_API_KEY" }}><AppRoutes /></GetUserFeedbackProvider>);}Props
| Prop | Type | Description |
|---|---|---|
children | ReactNode | App content that can access the client. |
clientOptions | ClientOptions | Public API key and initialization options. Required. |
instanceId | string | Deprecated runtime identity override. Omit it and let the provider own runtime identity. |
onError | (error: Error) => void | Receives runtime and command errors. |
webViewComponent | NativeWebViewComponent | Optional custom WebView component. It must forward received props and its ref to a compatible react-native-webview WebView whose ref exposes injectJavaScript. |
ClientOptions
Pass these customer-facing options through the provider's clientOptions prop.
Only apiKey is required.
| Option | Type | Description |
|---|---|---|
apiKey | string | Your project API key. |
properties | RuntimeProperties | JSON context for runtime targeting and analytics under existing consent. |
colorScheme | "light" | "dark" | "system" | Set a color scheme or follow the device setting with "system". |
defaultConsent | ConsentConfig | Initial consent decision or explicit list of granted scopes. Omission uses granted; set pending before load while a consent manager is waiting for a visitor decision. |
disableTelemetry | boolean | Disable anonymous performance telemetry. This does not disable user analytics. |
enableDebug | boolean | string | string[] | Enable debug logging globally or for selected namespaces. |
links | LinksConfig | Synchronously route authored HTTP(S) links in the host app. |
actions | ActionsConfig | NativeActionRegistration[] | Static custom actions. Prefer ActionsConfig. |
The package exports ConfigureOptions
for app-owned configuration helpers.
Set clientOptions.properties to provide root context. Supplied values are reapplied when the provider renders; omitting them leaves current context alone. Use configure({ properties }) to replace it and reset() to clear it. See Runtime properties for targeting and consent behavior.
For compatibility, ClientOptions still accepts the deprecated clientMeta
and runtimeEndpoints overrides. Application code should omit both: the
provider supplies canonical React Native metadata and uses the SDK's pinned
runtime.
Links (links)
Provide a synchronous router when your app owns link navigation:
<GetUserFeedbackProviderclientOptions={{apiKey: "YOUR_API_KEY",links: {router: ({ url }) => {appRouter.navigate(url);},},}}><App /></GetUserFeedbackProvider>The router receives url and the authored target ("self" or "blank",
when available). It must claim the request synchronously and return undefined.
Throwing or returning a promise-like value is terminal failure. 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. Without links, authored links are unavailable in React
Native.
Actions (actions)
Register custom actions through clientOptions.actions. Definitions remain
fixed for the provider's mounted lifetime, while the handler can be refreshed.
React Native does not support the legacy browser open-url registration.
See Actions for setup and behavior.
useGetUserFeedback()
Returns the provider's client. The hook must be called below
GetUserFeedbackProvider; otherwise it throws.
Client
| Member | Description |
|---|---|
instanceId | Deprecated runtime identity. Do not persist or branch on this value. |
configure(options, commandOptions?) | Update colorScheme, consent, or auth, or replace runtime context with properties. |
identify(userId, traits?, options?) | Associate a user ID, traits, and optional external IDs with the current user. |
identify(traits, options?) | Associate traits without a user ID. |
track(eventName, properties?, options?) | Record a product event with optional external IDs. See Events. |
screen(name?, properties?, options?) | Record a screen visit with an optional name and external IDs. See Events. |
feedback(answers, options?) | Submit feedback from your own UI. Resolves with { ok: true } after capture; rejects if submission fails. |
graph.connect(relationship) | Record that two product objects are connected. |
graph.disconnect(relationship) | Record that a recorded connection ended. |
flow(flowId) | Return a controller for one on-demand flow lifecycle. |
close() | Close every open flow owned by this provider. |
onOpenRequested(callback) | Observe persisted Flow opens before presentation. Call event.preventDefault() to keep an activation inactive. Returns an unsubscribe function. |
reset(commandOptions?) | Asynchronously close open flows, clear runtime properties and JWT authentication, and reset the current user identity. Appearance and consent remain in place. |
The package also exports GraphOperations, GraphRelationship, and
GraphRelationshipRef for typed relationship helpers.
For opt-in screen tracking from React Navigation, Expo Router, or another router, see React Native screen tracking. For Expo Router contextual targeting, see Current URL.
identify(), track(), and screen() accept external IDs through their
options argument. Some invalid input can throw before a command promise is
returned; other validation or command-processing failures reject that promise.
Use try/catch around an awaited call to handle both. See
Events for the shared pattern.
The commandOptions accepted by legacy command signatures still permits a
deprecated idempotencyKey. Omit it; the SDK owns command identity and
transport correlation.
The three-argument traits-only form, identify(traits, undefined, options?),
is also supported when a call site keeps options in the third argument.
Current URL
The existing useExpoRouterScreenTracking(pathname) integration also supplies
the current pathname for Current URL display conditions. No additional SDK
call is needed. For example, use /billing or /billing/* in the condition.
Expo's usePathname() supplies a path without a domain, query string, or fragment.
Conditions requiring those missing parts do not match. The React Navigation
adapter currently records screen visits but does not supply a current URL.
Calling screen() directly records a visit without changing the current URL.
Skipping a screen report with toScreen: () => null keeps Expo navigation updates
enabled.
client.feedback()
Submit feedback from your own UI using text, an Answer, or an array of answers.
The package exports Answer, FeedbackOptions, and FeedbackResult.
import { useGetUserFeedback } from "@getuserfeedback/react-native";import { useState } from "react";import { Button, TextInput, View } from "react-native";export function FeedbackForm() {const client = useGetUserFeedback();const [message, setMessage] = useState("Love this app!");return (<View><TextInputaccessibilityLabel="Your feedback"value={message}onChangeText={setMessage}multiline/><Buttontitle="Send feedback"onPress={() => void client.feedback(message).catch(console.error)}disabled={!message.trim()}/></View>);}For structured answers, form IDs and properties, see the JavaScript feedback reference.
client.onOpenRequested()
Register a synchronous observer for persisted Flow opens requested by an
explicit flow().open() call or client-side targeting:
const unsubscribe = client.onOpenRequested((event) => {if (event.source === "targeting") {event.preventDefault();}});The event includes source ("command" or "targeting") and flowId.
Supplied Flow metadata without a persisted flowId does not emit this event.
Call the returned function to unsubscribe.
client.flow(flowId)
Returns a FlowRun controller for one flow ID. Use the same controller when
prefetching, prerendering, opening, and closing one flow lifecycle.
const client = useGetUserFeedback();void client.flow("YOUR_FLOW_ID").open().catch((error) => console.error("Unable to open feedback", error));The flow must be published with Widget delivery and On-demand method.
The package exports OpenFlowOptions and PrerenderFlowOptions for typed
wrappers around these methods.
| Member | Description |
|---|---|
flowId | The flow ID passed to client.flow(). |
open(options?) | Open the flow. Options are hideCloseButton and metadata. See Response metadata. |
prefetch() | Load the flow's network resources before opening. |
prerender(options?) | Load the flow and warm its UI before opening. The option is hideCloseButton. |
close() | Close this flow lifecycle. |
All flow methods return promises. Use Open Widget flows from code for delivery and preparation patterns.
useFlow(options)
Use this hook for reactive state and commands for one on-demand flow:
const { open, close, prefetch, prerender, isOpen, isLoading } = useFlow({flowId: "YOUR_FLOW_ID",});Options are flowId, prefetchOnMount, and hideCloseButton. open() also
accepts response metadata. The hook exposes the same open(), close(),
prefetch(), and prerender() operations as client.flow(flowId).
React Native custom presentation remains provider-wide: use
useFlowContainer() and render one FlowContent rather than passing a
per-flow container to useFlow().
useFlowContainer()
Use this hook when your app owns the sheet, drawer, modal, or inline
presentation around a flow. It must be called below GetUserFeedbackProvider.
| Return value | Description |
|---|---|
isOpen | true when an active flow is visible. |
isLoading | true when an active flow is waiting for its measured size. |
shouldRenderContainer | true while your container should be visible, including while the flow is measuring. |
close() | Close every open flow owned by this provider. Returns a promise. |
Render one FlowContent inside the customer-owned container. Keep it mounted
while the container is closed so the projected flow can retain its state. See
the Containers guide for the complete
example.
FlowContent
FlowContent renders the active flow at its measured size inside your native
container. Mount it below GetUserFeedbackProvider, and mount only one
FlowContent for that provider. Do not render it conditionally with the
container's open state.
When FlowContent is not mounted, active flows use the SDK's built-in overlay.