Back

Documentation

Integration Guide

Get Reflekt running in your React Native or Expo app.

Supported Platforms

React Native
Expo
Flutter(coming soon)
iOS(coming soon)
Android(coming soon)

Installation

Install the Reflekt SDK:

npm install @reflekt/react-native

Peer 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-svg

Additional 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:

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:

App.tsx
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:

App.tsx or _layout.tsx
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:

apiKeyRequired

Your Reflekt API key

Type: string
respondentIdRequired

Unique identifier for the current user

Type: string
autoShow

Automatically show surveys when available

Type: booleanDefault: true
appVersion

Your app’s version string for analytics

Type: stringDefault: 'Unknown'
debug

Enable debug logging

Type: booleanDefault: false
pollIntervalMinutes

Interval for polling new surveys. Set to 0 to disable

Type: numberDefault: 60
apiUrl

Custom API URL for self-hosted or staging environments

Type: string

You can find your API key in the dashboard under Project Settings → API Keys.

Hooks

useReflekt

Access the SDK state within your components:

MyComponent.tsx
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

  1. 1Open Excel
  2. 2Go to File → Open and select your .csv file
  3. 3Data will automatically be parsed into columns

Google Sheets

  1. 1Go to sheets.google.com
  2. 2Click File → Import
  3. 3Select Upload and choose your .csv file
  4. 4Choose your import location and select "Comma" under "Separator type"
  5. 5Click Import data

Troubleshooting

Surveys not appearing

  1. 1Ensure your API key is correct
  2. 2Check that you have active surveys in your Reflekt dashboard
  3. 3Enable debug: true to see detailed logs
  4. 4Verify the respondentId hasn't already completed the survey

Questions? Send me an email.