Welcome to Encatch Docs
Mobile & Native SDKs

React Native SDK

Complete integration guide for the Encatch React Native SDK — in-app feedback and survey collection for React Native and Expo apps

The Encatch React Native SDK lets you collect in-app feedback and surveys in React Native and Expo apps. Display forms as a modal WebView overlay or inline in your layout, identify users, track screens and events, and submit responses to the Encatch backend.


Overview


Installation

npm install @encatch/react-native-sdk
yarn add @encatch/react-native-sdk
pnpm add @encatch/react-native-sdk

The SDK also requires these peer dependencies in your app:

npm install react-native-webview react-native-safe-area-context @react-native-async-storage/async-storage

Optional peers for automatic screen tracking and device metadata: @react-navigation/native, expo-router, expo-application, expo-device, expo-localization, react-native-device-info, and react-native-localize.


Quick Start

1. Initialization

Wrap your app's root with EncatchProvider to initialize the SDK, start a session, and optionally enable automatic screen tracking. Mount EncatchWebView once at the root for modal forms.

import { EncatchProvider, EncatchWebView } from '@encatch/react-native-sdk';

export default function App() {
  return (
    <EncatchProvider
      apiKey="your-api-key"
      navigationType="expo-router">
      <EncatchWebView />
      {/* Your app content */}
    </EncatchProvider>
  );
}

With React Navigation, put EncatchProvider inside your navigator instead of around your app: see Track screens below.

Use the useEncatch() hook inside any child component to access the SDK API. For inline forms, mount EncatchInlineForm in your screen component tree separately.

Pass an optional config object to customize SDK behavior:

<EncatchProvider
  apiKey="your-api-key"
  navigationType="expo-router"
  skippedRoutes={['/login', '/splash']}
  config={{
    theme: 'system',
    debugMode: true,
    isFullScreen: false,
    apiBaseUrl: 'https://api.encatch.com',
    webHost: 'https://form.encatch.com',
    appVersion: '1.2.3',
    appPackageId: 'com.example.app', // Your Android package name or iOS bundle ID
    onBeforeShowForm: async (payload) => {
      // Return false to prevent form from showing
      return true;
    },
  }}>
  <EncatchWebView />
  <App />
</EncatchProvider>

With React Navigation, EncatchProvider goes inside your navigator instead: see Track screens below.

Prop

Type

appPackageId is optional when the SDK can detect your app identifier. If neither expo-application nor react-native-device-info is installed, set it to your Android package name or iOS bundle ID, such as com.example.app.

Use onRequest and onResponse to see what the SDK sends while you develop, for example to count requests or spot rate-limited calls. A hook that throws is ignored. File uploads and AI Q&A streaming are not reported.

config={{
  onResponse: (info) => {
    console.log(info.endpoint, info.status, info.outcome, info.reason ?? '');
  },
}}

EncatchProvider props:

PropTypeDefaultDescription
apiKeystring—Your Encatch API key (required)
configEncatchConfig—SDK configuration
navigationType'expo-router' | 'react-navigation' | nullnullEnable automatic screen tracking. With 'react-navigation', the provider must be inside your navigator (see Track screens)
skippedRoutesstring[][]Routes to skip for screen tracking

2. Identify users

Identify the current user. The userName is required (can be a username, email, or unique identifier). Traits and options are optional.

Username format

userName must be an ASCII identifier: 1–50 characters, using only letters A–Z / a–z, digits 0–9, and ., _, @, -. Spaces and non-English characters (Unicode, accented letters, emoji, etc.) are not supported. Use an email address, internal user ID, or ASCII username — for example user@example.com or user_123. To store a display name in another language, pass it as a trait instead (e.g. $set: { display_name: '…' }).

Identify once per sign-in, not on every render

Call identifyUser when the user signs in, or when their traits change — never directly in a component body. A React component runs again on every render, and each identifyUser call is a network request that counts toward your rate limits. When a user goes over the limit, all of that user's calls are rejected for the rest of the minute, including the ones that show and submit surveys.

You don't need to identify again when the app restarts: the SDK saves the user on the device and restores them at startup. Call resetUser() when the user signs out.

From 1.4.4 the SDK skips an identifyUser call that repeats the last one exactly (same user, traits, locale, country and signature), but calling it from a component body is still a mistake: any changing value sends a new request.

// ❌ Don't: runs on every render of HomeScreen
function HomeScreen({ user }) {
  const { identifyUser } = useEncatch();
  identifyUser(user.id);
  // ...
}

Identify the user in the handler that completes sign-in:

import { useEncatch } from '@encatch/react-native-sdk';

function SignInScreen() {
  const { identifyUser } = useEncatch();

  const onSignIn = async (email: string, password: string) => {
    const user = await signIn(email, password); // your auth call
    identifyUser(user.email);
  };

  // ...
}

If your app keeps the signed-in user in state, identify from a useEffect that depends only on the user ID and the trait values you send. The effect runs again only when one of them changes:

import { useEffect } from 'react';
import { useEncatch } from '@encatch/react-native-sdk';

function EncatchIdentity({ user }: { user: { id: string; name: string; plan: string } | null }) {
  const { identifyUser } = useEncatch();
  const id = user?.id;
  const name = user?.name;
  const plan = user?.plan;

  useEffect(() => {
    if (!id) return;
    identifyUser(id, {
      $set: { name, plan },
    });
  }, [identifyUser, id, name, plan]);

  return null;
}

Mount it once near the root of your app, inside EncatchProvider. List individual values in the dependency array — not the whole user object or the object returned by useEncatch(), because those can be new objects on every render.

$increment and $decrement change the stored value on every call, so send them only from a one-time action such as sign-in, never from an effect that can run again:

const onSignIn = async (email: string, password: string) => {
  const user = await signIn(email, password); // your auth call

  identifyUser(user.email, {
    $set: { name: user.name, plan: user.plan },
    $setOnce: { firstSeen: new Date().toISOString() },
    $increment: { loginCount: 1 },
    $decrement: { credits: 5 },
    $unset: ['trialEndDate'],
  });
};

Prop

Type

User traits support the following operations:

OperationDescription
$setSet user attributes (overwrites existing values)
$setOnceSet user attributes only if they don't already exist
$incrementIncrement numeric user attributes
$decrementDecrement numeric user attributes
$unsetRemove user attributes

Recommended

Using the secure option with a server-generated signature is recommended to verify that identification requests come from your backend. Keep your secret key on the server only — never expose it in client-side code.

Pass a server-generated HMAC signature so Encatch can validate the request. Requires SDK 1.4.4 or later: earlier versions didn't send the signature in the way the API checks it, so secure identification failed.

generatedDateTimeinUTC must be milliseconds since the Unix epoch, as a string (for example String(Date.now()) on your server). When your publishable key has a session timeout, your server signs HMAC-SHA256(userName + generatedDateTimeinUTC, secretKey) and the time limits how long the signature is valid.

identifyUser('user@example.com', undefined, {
  secure: {
    signature: 'your-hmac-signature',
    generatedDateTimeinUTC: '1741867200000', // ms since epoch (2025-03-13T12:00:00Z)
  },
});

After a successful secure identify, the SDK sends the signature with every request for that user and saves it on the device, so it survives an app restart. A later identifyUser replaces it, an identifyUser without secure removes it, and so do resetUser() and switching users.

Keys with a session timeout: fetch a fresh signature from your server and identify again on every app launch. When the signature expires, the SDK logs one warning and pauses background requests until the next successful secure identify. A survey answer submitted meanwhile is kept in memory and sent after that identify.

3. Show a form manually

Show a specific form by slug or ID.

Call showForm from a user action, such as a button press. Calling it again for the form that's already loading or open does nothing, so answers in progress aren't lost; showing a different form replaces the open one.

import { Button } from 'react-native';
import { useEncatch } from '@encatch/react-native-sdk';

function HelpScreen() {
  const { showForm } = useEncatch();

  return (
    <Button
      title="Give feedback"
      onPress={() => showForm('feedback-form', { reset: 'always' })}
    />
  );
}

Prop

Type

Prop

Type

Reset modeBehavior
'always'Reset pre-fill and response data on every form display
'on-complete'Reset only after the form is completed
'never'Never reset response data

Pass caller context when showing a form:

showForm('feedback-form', {
  reset: 'always',
  context: { plan: 'team', feature: 'checkout' },
});

Other actions

Set the user's preferred language.

const { setLocale } = useEncatch();

setLocale('fr');

Set the user's country.

const { setCountry } = useEncatch();

setCountry('FR'); // ISO 3166 country code

Set the theme for forms and surveys.

const { setTheme } = useEncatch();

setTheme('dark');
setTheme('light');
setTheme('system'); // Follows system preference

Each trackEvent call is a network request, so call it once per real user action: from an event handler, or from an effect that runs once.

import { useEffect } from 'react';
import { Button } from 'react-native';
import { useEncatch } from '@encatch/react-native-sdk';

function CheckoutScreen() {
  const { trackEvent } = useEncatch();

  // Once when the screen mounts — not in the component body
  useEffect(() => {
    trackEvent('checkout_opened');
  }, [trackEvent]);

  return <Button title="Pay" onPress={() => trackEvent('pay_clicked')} />;
}

With React Navigation, screens can stay mounted when the user moves away and back. To send an event on every visit, use useFocusEffect from @react-navigation/native with a useCallback instead of useEffect.

Set navigationType on EncatchProvider and the SDK tracks screens for you (below). If you track screens yourself, call trackScreen from an effect, never in the component body:

const { trackScreen } = useEncatch();

useEffect(() => {
  trackScreen('HomeScreen');
}, [trackScreen]);

For automatic tracking, where EncatchProvider goes depends on your navigation library:

Put the provider in your root layout, around the navigator:

app/_layout.tsx
import { Stack } from 'expo-router';
import { EncatchProvider, EncatchWebView } from '@encatch/react-native-sdk';

export default function RootLayout() {
  return (
    <EncatchProvider apiKey="your-api-key" navigationType="expo-router">
      <EncatchWebView />
      <Stack />
    </EncatchProvider>
  );
}

The SDK sends the route's path: app/settings.tsx is /settings. Group folders are left out (app/(tabs)/settings.tsx is /settings too), and a dynamic route sends its value (app/user/[id].tsx is /user/123).

Put the provider inside your navigator, not around NavigationContainer or the navigator. The SDK reads the navigation state with useNavigationState, which React Navigation 7 allows only inside a navigator. Placed outside, the app stops at launch with Couldn't get the navigation state. Is your component inside a navigator?

The navigator's layout prop wraps its screens, so it is a good place for the provider:

import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { EncatchProvider, EncatchWebView } from '@encatch/react-native-sdk';

const Stack = createNativeStackNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator
        layout={({ children }) => (
          <EncatchProvider
            apiKey="your-api-key"
            navigationType="react-navigation"
            skippedRoutes={['/Login']}>
            <EncatchWebView />
            {children}
          </EncatchProvider>
        )}>
        <Stack.Screen name="Home" component={HomeScreen} />
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="Settings" component={SettingsScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

The SDK sends / and the name of the screen being shown: the screen Settings is /Settings. A screen in a nested navigator is sent by its own name too (Settings inside a Profile stack is /Settings), so give screens in different navigators different names if you want to tell them apart.

Give the provider to your outermost navigator: it sees every screen, nested ones included, and it stays mounted. The provider starts the SDK and stops it when it unmounts, so it should not sit in a navigator that your app swaps out, such as one shown only after sign-in.

The first screen is sent once the SDK is ready. After that a screen is sent each time the route changes, including when the user comes back to a screen they left.

Use skippedRoutes to exclude routes such as login or splash screens. Each entry is a whole path as the SDK sends it (/Login, /settings); case does not matter.

Subscribe to form lifecycle events. Returns an unsubscribe function.

const { on } = useEncatch();

useEffect(() => {
  const unsubscribe = on((eventType, payload) => {
    console.log('Event:', eventType, payload.data);
  });
  return unsubscribe;
}, [on]);
EventDescription
form:showFired when a form is displayed
form:startedFired when a user starts interacting
form:submitFired when a form is submitted
form:completeFired when a form is fully completed
form:closeFired when a form is closed
form:dismissedFired when an identified user closes a form with its X before the final submit. Not fired for visitors, on the thank-you screen, for "Remind me later" or for call-to-action buttons
form:errorFired when an error occurs
form:section:changeFired when the visible section changes
form:answeredFired when a question is answered
form:remindmelaterFired when the user taps "Remind me later". Not a dismissal
form:ctaTriggeredFired when a completion CTA is triggered on thank-you or exit screens

When formId isn't known from the form page, events carry the ID of the form the SDK opened (1.4.4+), so it is not empty.

Handle completion CTAs (in-app navigation, internal redirect, or external browser) via form:ctaTriggered. Configure actions in the form builder — see Call to action. The SDK closes the form overlay after emitting the event — your app handles in-app navigation:

const { on } = useEncatch();
const router = useRouter(); // expo-router

useEffect(() => {
  const handler = (eventType, payload) => {
    if (eventType !== 'form:ctaTriggered') return;

    const action = payload.data?.action;
    if (action !== 'app_navigate') return;

    const route = payload.data?.route as string | undefined;
    // Map route strings to your app's navigation paths
    if (route === 'billing' || route === 'billing/upgrade') {
      router.push('/billing');
    }
  };

  const unsubscribe = on(handler);
  return unsubscribe;
}, [on, router]);

For in-app navigation, the SDK closes the form overlay after emitting the event and expects your app to perform navigation. For URL redirect actions, the SDK opens the URL and closes the form automatically.

Pre-fill a form response before showing a form. questionId may be a question UUID or a question slug.

const { addToResponse, showForm } = useEncatch();

const openSurvey = () => {
  addToResponse('question_id', 'pre-filled value');
  addToResponse('choice_question_id', ['option-a', 'option-b']);

  showForm('your-form-slug');
};

Dismiss the currently displayed form.

const { dismissForm } = useEncatch();

dismissForm();
// Or dismiss a specific form configuration:
dismissForm('config-id');

Use onBeforeShowForm in EncatchProvider config to conditionally block forms from showing.

<EncatchProvider
  apiKey="your-api-key"
  config={{
    onBeforeShowForm: async (payload) => {
      // Inspect payload.formId, payload.formConfig, payload.triggerType, etc.
      if (payload.triggerType === 'automatic' && someCondition) {
        return false; // Block this form
      }
      return true; // Allow
    },
  }}>
  <EncatchWebView />
  <App />
</EncatchProvider>

EncatchProvider starts a session automatically after initialization, unless stopSession() was called earlier. You can also control session lifecycle manually via the Encatch singleton:

import { Encatch } from '@encatch/react-native-sdk';

await Encatch.startSession();

// Skip the immediate ping or screen re-track on start:
await Encatch.startSession({
  skipImmediatePing: true,
  skipImmediateTrackScreen: true,
});
// Temporarily stop the 30-second background ping (not persisted)
Encatch.pauseSession();

// Resume the ping interval after pauseSession()
Encatch.resumeSession();
await Encatch.stopSession();

stopSession() stops the SDK's automatic traffic until you turn it back on:

  • What stops: the background ping and automatic screen tracking from navigationType. An open form closes, and a pending automatic one is cancelled.
  • How long: saved on the device, so it lasts across app restarts until startSession() or a successful identifyUser(). resetUser() also clears it.
  • What still works: your own trackScreen(), trackEvent(), identifyUser() and showForm() calls, and form submissions. A form the server picks in reply to one of those calls still shows.

Before 1.4.4 the stop didn't survive a restart, because EncatchProvider started a new session on every launch.

Reset the current user identity and clear persisted identity data. Reverts the SDK to anonymous mode. User identity is preserved across stopSession() — use resetUser() after logout.

const { resetUser } = useEncatch();

const onSignOut = async () => {
  await signOut(); // your auth call
  resetUser();
};

Wipes all persisted SDK data and resets in-memory state. Stronger than resetUser() — also clears session-stopped state and device preferences. Call Encatch.init() again before further use.

await Encatch.clearAll();

The SDK sends a background ping to maintain engagement sessions and check for triggered forms: every 30 seconds by default, or after the interval the server asks for in its reply. Ping is suppressed while a form is visible.

Each SDK call is a network request that counts toward your rate limits. From 1.4.4 the SDK keeps request volume down and backs off by itself:

  • Repeated calls: an identifyUser that repeats the last one is skipped, and identical trackEvent or trackScreen calls within 1 second are sent once. Automatic screen tracking sends a screen only when the route changes.
  • One form at a time: while a form is loading or open, forms picked by the server are ignored.
  • When the API answers 429 Too Many Requests: the call isn't retried, and that group of calls pauses for the time in the Retry-After header (60 seconds without it, at most 5 minutes). Calls made during the pause are skipped, and the SDK logs one warning per pause.
  • Exceptions: a survey answer is never dropped; it waits for the pause to end and is retried. An identifyUser made during a pause is sent when the pause ends.
  • Other failures: identify, event and screen calls that fail with a network or server error are tried up to 3 times in total; other 4xx errors aren't retried. Every request times out after 30 seconds.

Use the onResponse hook to see skipped and rate-limited calls while you develop.


Inline Forms

Inline forms are a way to show Encatch in-app feedback without a modal — the survey renders directly in your layout instead of as a full-screen overlay.

EncatchInlineForm renders a form directly inside your component tree instead of as a full-screen modal overlay. Place it anywhere — in a ScrollView, View, card, etc.

import { EncatchInlineForm, useEncatch } from '@encatch/react-native-sdk';

function FeedbackScreen() {
  const { showForm } = useEncatch();

  return (
    <ScrollView contentContainerStyle={{ padding: 16 }}>
      {/* ... content above ... */}
      <EncatchInlineForm
        formId="your-form-slug" // exact match; omit for wildcard
        minHeight={100}
        style={{ borderRadius: 12, overflow: 'hidden' }}
      />
      {/* ... content below ... */}
    </ScrollView>
  );
}

// Then trigger the form from anywhere:
showForm('your-form-slug');

When showForm is called, the SDK resolves the presenter in this order:

  1. Exact match — first registered EncatchInlineForm whose formId matches the payload wins.
  2. Wildcard — first registered EncatchInlineForm with no formId catches anything not exact-matched.
  3. Modal fallback — EncatchWebView shows the form as the default overlay when no inline slot is registered or none match.

When @react-navigation/native is installed, EncatchInlineForm registers its inline slot only while the screen is focused (via useIsFocused). Background tab screens do not intercept showForm calls meant for the modal.

If you use a tab navigator that keeps screens mounted in the background, ensure inline slots are on focused screens only. The encatch-expo-tester sample app demonstrates exact and wildcard inline tabs with scroll-into-view when QnA/Scheduler overlays open.

When a screen loses focus, its slot is unregistered, so showForm falls through to the modal or another active slot.

The WebView's internal scroll is disabled. The host ScrollView (or FlatList) provides scrolling. The widget height grows automatically via form:resize messages from the web form.

<ScrollView>
  <EncatchInlineForm formId="my-form" />
</ScrollView>

The host app controls keyboard avoidance. Use KeyboardAvoidingView, automaticallyAdjustKeyboardInsets, or scroll-into-view when the keyboard opens — WebView focus is not native, so the SDK does not shrink on keyboard.

PropTypeDefaultDescription
formIdstring—Exact form slug/id to match. Omit for wildcard.
styleStyleProp<ViewStyle>—Outer container layout style.
minHeightnumber0Minimum height floor applied after form:resize.
onOverlayOpenChange(open: boolean) => void—Called when a QnA/Scheduler overlay opens or closes.

Build Your Own Form UX & UI

If your feedback flow uses a fixed, predictable question set — the same fields and workflow every time — you can build the form with your own React Native components and submit responses through the SDK. That keeps typography, spacing, colors, and interaction patterns aligned with the rest of your app, so the survey feels like a native screen rather than an embedded web page.

Example coming soon.


MethodDescription
init(apiKey, config?)Initialize the SDK
identifyUser(userName, traits?, options?)Identify a user
setLocale(locale)Set locale
setCountry(country)Set country (ISO 3166)
setTheme(theme)Set form theme
trackEvent(eventName)Track a custom event
trackScreen(screenName)Track screen navigation
showForm(formId, options?)Show a form (inline or modal)
dismissForm(formConfigurationId?)Dismiss the current form
addToResponse(questionId, value)Pre-fill a question answer
startSession(options?)Start a new session
pauseSession()Pause background ping
resumeSession()Resume background ping
stopSession()Suspend SDK activity
resetUser()Reset user identity
clearAll()Wipe all persisted SDK data
on(callback)Subscribe to lifecycle events
off(callback)Unsubscribe from events
submitForm(params)Submit a custom native form
refineText(params)AI text refinement
uploadFile(params)Upload a file (custom native forms)
streamQnaWithAi(params, callbacks)Stream Q&A with AI answers
stop()Teardown (called by provider on unmount)

Use useEncatch() for the same API inside React components. The following are available on the Encatch singleton only (not exposed via useEncatch()): init, startSession, pauseSession, resumeSession, stopSession, clearAll, uploadFile, streamQnaWithAi, stop.

The SDK never asks for camera or microphone access by itself. iOS shows the system prompt only when a form question needs it (a photo, video or audio answer), the first time that question is used. If your forms don't use those question types, you don't need to add anything.

Add usage descriptions to your app's Info.plist (or app.json for Expo) when forms include video/audio capture:

<key>NSCameraUsageDescription</key>
<string>Encatch forms use the camera to record video responses.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Encatch forms use the microphone to record audio and video responses.</string>

Expo app.json example:

{
  "expo": {
    "ios": {
      "infoPlist": {
        "NSCameraUsageDescription": "Allow Encatch to capture photos, videos, and signatures for form responses.",
        "NSMicrophoneUsageDescription": "Allow Encatch to record audio for form responses."
      }
    }
  }
}

The SDK uses react-native-webview, which handles WebView media permission requests once these keys are present.

Add permissions to android/app/src/main/AndroidManifest.xml (or app.json for Expo):

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

Expo app.json example:

{
  "expo": {
    "android": {
      "permissions": ["CAMERA", "RECORD_AUDIO", "MODIFY_AUDIO_SETTINGS"]
    }
  }
}

INTERNET is required for API calls and the form WebView. The other three permissions are required only when forms include video/audio capture questions (video_audio). If your forms don't use them, leave them out and your users are never asked.

The SDK never asks for camera or microphone access by itself. When a form question needs one of them, the WebView asks the user for runtime permission the first time that question is used. Your app doesn't need to request these permissions at startup.

Support

Was this page helpful?