Skip to main content
The React Native SDK, @tryproduck/react-native, puts the Produck duck in your app. A user taps the duck, or accepts an offer from one of your campaign’s triggers, and talks with the interviewer. The interviewer reads the screen the user is on, points at what they mean and, if you allow it, taps and types for them.

Before you start

  • React Native 0.82 or later. On an older version the SDK starts nothing and says so on the console.
  • A development build. The SDK ships native code (WebRTC and audio), so it does not run in Expo Go. Build the app with npx expo run:ios or npx expo run:android, or with EAS.
  • Your SDK key, from Settings › SDK in the dashboard. It starts with pk_live_.

Set up with one command

Run this in your app’s folder, with your key:
Settings › SDK shows this command with your key filled in. The wizard works in an Expo app and in a React Native app without Expo. It shows every change and asks once before it makes any. Then it:
  1. Installs your app’s own packages first when they are not installed, from your lockfile without changing it (npm ci, pnpm install --frozen-lockfile, yarn install --frozen-lockfile or --immutable, bun install --frozen-lockfile), then the latest SDK and the native libraries your app lacks. It keeps a library your app already has. If one is older than the SDK supports, it stops before any change and names it, so you can upgrade it first. After the install it checks each version and tells you if one is still too old.
  2. Adds the SDK’s config plugin to app.json in an Expo app.
  3. Adds the microphone and camera texts to Info.plist and the call permissions to AndroidManifest.xml, when the app has ios/ or android/ folders.
  4. Wraps your app’s root component in withProduck, with your key.
  5. Lists the files it changed, and prints any step it could not do safely, for you to do by hand.
Then rebuild the app, and check that it works.
Commit or stash your work before you run the wizard, so you can review its changes with git diff. The wizard warns you when the folder has uncommitted changes.

Run it from a coding agent

A coding agent’s shell has no terminal for the wizard to ask in. Add --yes to make the changes without asking:
With --yes the wizard still lists the uncommitted files, every change and the steps left by hand. It stops before any change when it finds no lockfile, or lockfiles of more than one package manager; name the app’s manager with --package-manager npm, yarn, pnpm or bun to go on. The AGENTS.md block on Settings › SDK tells your agent to run it this way.

Set up by hand

1. Install the packages. Let Expo pick the versions of these three:
Install the rest with your package manager (npm, yarn, pnpm or bun), not with npx expo install. The SDK’s config plugin sets them up, so Expo must not add their own plugins:
2. Add the config plugin to app.json:
app.json
The plugin adds the microphone and camera texts on iOS, the call permissions on Android and the audio library’s own setup. To use your own texts, pass them as options:
app.json
If your config is app.config.js or app.config.ts, add the same entry to its plugins list.3. Wrap your app.4. Rebuild with npx expo run:ios or npx expo run:android. The plugin changes native files, so a reload of the JavaScript is not enough.
npx expo run:ios and npx expo run:android apply the plugin only when they create the ios/ or android/ folder. If your app already has these folders, also make steps 2 to 6 of the React Native tab.

Wrap your app

Wrap your root component once. Use withProduck on the default export:
App.tsx
Or render <ProduckProvider> around your app. Both take the same options:
App.tsx
With Expo Router, wrap the default export of app/_layout.tsx (or src/app/_layout.tsx).

Check that it works

  1. Start the development build on a phone or a simulator.
  2. Find the duck in the bottom-right corner.
  3. Tap the duck and allow the microphone.
  4. Hold Hold to talk and say something. The interviewer answers through the loudspeaker.
  5. Tap the stop button on the bar to end the call.
No duck? Look in the console for a line that starts with Produck: not started. It names the cause. See Troubleshooting.

How an interview works

  1. It starts with a tap. The user taps the duck, or accepts an offer that one of your triggers showed. The SDK asks for the microphone only then.
  2. The record bar opens at the bottom of the screen. It shows the interviewer’s current line above it. The user holds Hold to talk to speak, or opens the tools and types an answer. The microphone is open only while they hold the button.
  3. The interviewer reads the screen. It knows the screen’s buttons, fields and text by their names. It can point at an element with a ring and a label, and scroll to it.
  4. It can act, if you allow it. With Settings › Agent › Help level set to Acts, the interviewer can tap a control or type into a field for the user. With Shows, it only points.
  5. The call ends when the user taps the bar’s stop button, when the app goes to the background, or when another app, such as a phone call, takes the sound for good.
An interview in a phone app keeps no recording of the screen or the sound, and files no ticket. During the call the SDK notes the user’s taps, the screens they visited, the app’s errors and its failed network requests, for the interviewer. It never notes the text the user typed.

Tell Produck who the user is

Call identify from useProduck() once you know who the user is, for example right after sign-in. Pass null to forget them, for example at sign-out:
An identity needs a userId or an email. If a value breaks a rule, the SDK keeps no identity and logs one console error that names the field. useProduck() works only inside the wrapped app. Outside it, it throws.

Offer an interview at the right moment

A campaign’s triggers offer its interview. Each trigger on the campaign’s Triggers tab has an id. When the moment it describes happens in your app, fire it:
The SDK shows an offer with the trigger’s words, or “Got a minute to tell us how that went?”. When the user accepts, the interview starts under that trigger.
  • A trigger offers at most once per run of the app. Pass { repeat: true } to offer it again: produck.fire("TRIGGER_ID", { repeat: true }).
  • A fire shows nothing, and says why on the console, when the trigger is not active, another offer is showing, or an interview is already running. A fire during an interview does not count, so the trigger can still offer after the call.

Fire triggers from PostHog events

A trigger can fire on a PostHog event instead of a call. Set Fires on to PostHog trigger on the campaign’s Triggers tab, and pass your posthog-react-native client to the SDK:
App.tsx
The SDK then fires a trigger whenever your app captures its event and the trigger’s filters pass. If you use <PostHogProvider>, give it the same client with its client prop, so both read one PostHog.

Keep parts of the screen private

Wrap anything the interviewer must not read in <ProduckMask>. It adds no view, so your layout does not change:
The interviewer does not see, point at or touch anything inside a mask. Some fields it never types into, masked or not:
  • password fields (secureTextEntry);
  • one-time-code and payment-card fields;
  • fields whose testID or nativeID names a secret, such as card-number.
The interviewer also never sees text the user typed into a field.

Place the duck

Pass launcher to choose where the duck sits:

Match the offer to your app

Pass theme to give the offer your colours, corners and font. Every option is optional; an option you leave out keeps Produck’s look:

Options

withProduck(App, options) and <ProduckProvider> take these options:

Troubleshooting

If the bar says Your interviewer couldn’t connect. Try again., check the network and that the key in apiKey is a live key from Settings › SDK. If the bar says This interview needs your microphone., the user refused the microphone. On iOS they can allow it again in the Settings app.