@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:iosornpx 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:- 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-lockfileor--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. - Adds the SDK’s config plugin to
app.jsonin an Expo app. - Adds the microphone and camera texts to
Info.plistand the call permissions toAndroidManifest.xml, when the app hasios/orandroid/folders. - Wraps your app’s root component in
withProduck, with your key. - Lists the files it changed, and prints any step it could not do safely, for you to do by hand.
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:
--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
- Expo
- React Native
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 2. Add the config plugin to 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:If your config is
npx expo install.
The SDK’s config plugin sets them up, so Expo must not add their own plugins:app.json:app.json
app.json
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. UsewithProduck on the default export:
App.tsx
<ProduckProvider> around your app. Both take the same options:
App.tsx
app/_layout.tsx (or src/app/_layout.tsx).
Check that it works
- Start the development build on a phone or a simulator.
- Find the duck in the bottom-right corner.
- Tap the duck and allow the microphone.
- Hold Hold to talk and say something. The interviewer answers through the loudspeaker.
- Tap the stop button on the bar to end the call.
Produck: not started. It names the cause.
See Troubleshooting.
How an interview works
- 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.
- 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.
- 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.
- 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.
- 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
Callidentify 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:- 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 yourposthog-react-native client to the SDK:
App.tsx
<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:
- password fields (
secureTextEntry); - one-time-code and payment-card fields;
- fields whose
testIDornativeIDnames a secret, such ascard-number.
Place the duck
Passlauncher to choose where the duck sits:
Match the offer to your app
Passtheme 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.