Skip to content

React Native

The React Native wrapper is a thin bridge over the native iOS and Android SDKs. Surveys render as fully native UI, no survey UI lives in JavaScript. It exposes exactly what the native SDKs expose and, like them, is fire-and-forget: calls do not report outcomes, and failures are logged natively rather than surfaced to JavaScript.

It is a Turbo Module, so it requires the New Architecture.

Terminal window
yarn add react-native-whiskrkit

The native WhiskrKit SDK is a Swift package, consumed through the cocoapods-spm plugin:

Terminal window
gem install cocoapods-spm

In your app’s Podfile, declare the plugin and package source, and set the platform to at least iOS 17:

platform :ios, '17.0'
plugin 'cocoapods-spm'
target 'YourApp' do
spm_pkg "WhiskrKit",
:url => "https://github.com/whiskrkit/whiskrkit-swift.git",
:version => "0.1.10"
# ...
end

Then cd ios && pod install.

The eu.whiskrkit:whiskrkit-android dependency resolves from Maven Central with no extra setup. Just make sure your app’s minSdkVersion is 26 or higher.

initialize, present, and checkAndPresent are synchronous and return nothing; useWhiskrKitSurvey is a React hook. initialize must be called before the others; calls made without it are silent no-ops (logged natively). Attachment to the host app’s window happens automatically on initialize; there is no view or component to mount.

import {
initialize,
present,
checkAndPresent,
useWhiskrKitSurvey,
} from 'react-native-whiskrkit';

Initialises the SDK and attaches WhiskrKit to your app. Call once, at startup.

initialize('wk_live_your_api_key');
// With mocked surveys for local development:
initialize('any-string', { withMockedSurveys: true });
ParameterTypeDescription
apiKeystringYour WhiskrKit API key from the dashboard
options?{ withMockedSurveys?: boolean }When withMockedSurveys is true, uses local mock data instead of the API

Imperatively presents a survey, bypassing eligibility checks. Use for a feedback button, a push-notification handler, or any trigger you own.

present('nps-survey');
ParameterTypeDescription
surveyIdstringThe identifier of the survey to present

Checks eligibility and presents a survey if the user qualifies. The timing is yours; the targeting decision stays with the backend.

checkAndPresent('settings-feedback');
ParameterTypeDescription
surveyIdstringThe identifier of the survey to evaluate and potentially present

A React hook that presents a survey automatically when a component mounts. This is the wrapper’s equivalent of the native automatic presentation (SwiftUI’s .whiskrKitSurvey modifier, Jetpack Compose’s WhiskrKitSurvey): call it inside a screen component and a survey appears on that screen, subject to eligibility. Under the hood it runs checkAndPresent on mount, and again if surveyId changes.

import { useWhiskrKitSurvey } from 'react-native-whiskrkit';
function FeedbackScreen() {
useWhiskrKitSurvey('nps-survey');
return <YourScreen />;
}
ParameterTypeDescription
surveyIdstringThe identifier of the survey to evaluate and potentially present

Fire-and-forget, silent failure. The native SDKs never surface errors or survey lifecycle events, so neither does the wrapper: there are no promises to await, no event emitter, and no error codes. When debugging, watch the native logs: Console.app (subsystem WhiskrKit) on iOS, Logcat (tag WhiskrKit) on Android.

No theming API. Theming is native-only (SwiftUI setTheme on iOS, WhiskrKitHost(theme:) on Android) and is not exposed through the wrapper. Surveys use the SDK defaults.

RequirementMinimum
React Native0.85+ (New Architecture)
iOS17.0
Android minSdk26