Integration Guide
Get Reflekt running in your React Native or Expo app.
Supported Platforms
Installation
Install the Reflekt SDK:
npm install @reflekt/react-nativePeer Dependencies
This package requires the following peer dependencies:
npm install @react-native-async-storage/async-storage react-native-gesture-handler react-native-reanimated react-native-svgAdditional Setup
React Native Reanimated
Note: We currently use React Native Reanimated 3, not version 4.
Add the Reanimated Babel plugin to your babel.config.js:
module.exports = {
plugins: ['react-native-reanimated/plugin'],
};React Native Gesture Handler
For React Native (non-Expo) projects, wrap your app with GestureHandlerRootView:
import { GestureHandlerRootView } from 'react-native-gesture-handler';
export default function App() {
return (
<GestureHandlerRootView style={{ flex: 1 }}>
{/* Your app content */}
</GestureHandlerRootView>
);
}For Expo projects, this is handled automatically.
Quick Start
So easy you don't even need to make Claude do it.
Wrap your app with ReflektProvider inside your GestureHandlerRootView:
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { ReflektProvider } from '@reflekt/react-native';
export default function App() {
return (
<GestureHandlerRootView>
<ReflektProvider
config={{
apiKey: process.env.EXPO_PUBLIC_REFLEKT_API_KEY,
respondentId: user.id
}}
>
<YourApp />
</ReflektProvider>
</GestureHandlerRootView>
);
}But if you're lazy, here you go:
Provider Placement
Important: Place ReflektProvider in an authenticated section of your app.
Surveys automatically appear as popups when they become available at the level of the ReflektProvider. This means:
- The provider should be placed after authentication, so you have access to a unique identifier for the user
- All screens wrapped by the provider can receive survey popups
- Surveys trigger automatically when published
Coming soon: More precise targeting options to control exactly when and where surveys appear.
Configuration
The ReflektProvider accepts a config object with the following properties:
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
| apiKey | string | Yes | - | Your Reflekt API key |
| respondentId | string | Yes | - | Unique identifier for the current user |
| autoShow | boolean | No | true | Automatically show surveys when available |
| appVersion | string | No | 'Unknown' | Your app’s version string for analytics |
| debug | boolean | No | false | Enable debug logging |
| pollIntervalMinutes | number | No | 60 | Interval for polling new surveys. Set to 0 to disable |
| apiUrl | string | No | - | Custom API URL for self-hosted or staging environments |
apiKeyRequiredYour Reflekt API key
respondentIdRequiredUnique identifier for the current user
autoShowAutomatically show surveys when available
trueappVersionYour app’s version string for analytics
'Unknown'debugEnable debug logging
falsepollIntervalMinutesInterval for polling new surveys. Set to 0 to disable
60apiUrlCustom API URL for self-hosted or staging environments
You can find your API key in the dashboard under Project Settings → API Keys.
Hooks
useReflekt
Access the SDK state within your components:
import { useReflekt } from '@reflekt/react-native';
function MyComponent() {
const { isReady } = useReflekt();
if (!isReady) {
return <LoadingSpinner />;
}
return <YourContent />;
}Advanced Usage
Manual SDK Control
For advanced use cases, you can interact with the SDK directly:
import { ReflektSDK } from '@reflekt/react-native';
// Check if SDK is initialized
if (ReflektSDK.isInitialized()) {
const sdk = ReflektSDK.getInstance();
// Get available surveys
const surveys = await sdk.getAvailableSurveys();
// Reload surveys from the server
await sdk.reloadAvailableSurveys();
// Get the current theme
const theme = sdk.getTheme();
}
// Reset the SDK (e.g., on user logout)
ReflektSDK.reset();Handling User Logout
When a user logs out, reset the SDK to clear cached data:
async function handleLogout() {
ReflektSDK.reset();
// ... rest of your logout logic
}Theming
Surveys automatically inherit your project's theme from the Reflekt dashboard. The theme includes:
- Colors: Background, text, primary accent, and more
- Border Radius: Customizable corners for sheets, buttons, inputs
Question Types
The SDK supports the following question types:
- Free Text: Open-ended text responses
- Single Select: Radio button selection
- Multi Select: Checkbox selection
- Rating: Star, number, or emoji scales (3-10 range)
- Message: Informational screens (no response required)
Requirements
- React Native >= 0.64.0
- React >= 17.0.0
- iOS 12.0+ / Android API 21+
Rate Limits
The default rate limit is 1,000 responses per hour per API key.
If you need higher limits, send me an email and we'll work something out.
Exporting Data
Export your survey responses from the dashboard in CSV format. Here's how to import the data into your preferred spreadsheet app:
Excel
- 1Open Excel
- 2Go to File → Open and select your .csv file
- 3Data will automatically be parsed into columns
Google Sheets
- 1Go to sheets.google.com
- 2Click File → Import
- 3Select Upload and choose your .csv file
- 4Choose your import location and select "Comma" under "Separator type"
- 5Click Import data
Troubleshooting
Surveys not appearing
- 1Ensure your API key is correct
- 2Check that you have active surveys in your Reflekt dashboard
- 3Enable
debug: trueto see detailed logs - 4Verify the
respondentIdhasn't already completed the survey
Questions? Send me an email.