Skip to content

React Native SDK ​

Integrate Klero feedback, roadmap, changelog, surveys, and widgets into your React Native app.

Requirements ​

  • React Native >= 0.60.0
  • react-native-webview >= 11.0.0

Installation ​

bash
npm install @kleroai/react-native react-native-webview

For iOS, run pod install:

bash
cd ios && pod install

Quick Start ​

Any Module with KleroEmbed ​

KleroEmbed is the generic component that supports all Klero module types. Convenience wrappers are also provided.

tsx
import { KleroEmbed, KleroFeedback, KleroRoadmap, KleroChangelog, KleroWidget } from '@kleroai/react-native';

// Using the generic component
<KleroEmbed projectSlug="myproject" embedType="feedback" />

// Or use convenience components
<KleroFeedback projectSlug="myproject" />
<KleroRoadmap projectSlug="myproject" />
<KleroChangelog projectSlug="myproject" />
<KleroWidget projectSlug="myproject" />

Survey with KleroSurvey ​

For surveys, use the dedicated KleroSurvey component which provides survey-specific event callbacks:

tsx
import { KleroSurvey } from '@kleroai/react-native';

function SurveyScreen() {
  return (
    <KleroSurvey
      projectSlug="myproject"
      surveyUlid="01ABC123..."
      onComplete={(data) => {
        console.log('Completed:', data.responseUlid);
        console.log('Answers:', data.answers);
      }}
      onClose={(data) => {
        console.log('Closed, completed:', data.completed);
      }}
      onError={(error) => {
        console.error('Error:', error);
      }}
    />
  );
}

Programmatic Control ​

KleroEmbed ​

tsx
import { useRef } from 'react';
import { KleroEmbed, KleroEmbedHandle } from '@kleroai/react-native';

function FeedbackScreen() {
  const embedRef = useRef<KleroEmbedHandle>(null);

  return (
    <>
      <Button title="Reload" onPress={() => embedRef.current?.reload()} />
      <KleroEmbed
        ref={embedRef}
        projectSlug="myproject"
        embedType="feedback"
      />
    </>
  );
}

KleroSurvey ​

tsx
import { useRef } from 'react';
import { KleroSurvey, KleroSurveyHandle } from '@kleroai/react-native';

function SurveyScreen() {
  const surveyRef = useRef<KleroSurveyHandle>(null);

  return (
    <>
      <Button title="Open" onPress={() => surveyRef.current?.open()} />
      <Button title="Close" onPress={() => surveyRef.current?.close()} />
      <KleroSurvey
        ref={surveyRef}
        projectSlug="myproject"
        surveyUlid="01ABC123..."
      />
    </>
  );
}

Widget Events ​

Listen for widget open/close events:

tsx
<KleroWidget
  projectSlug="myproject"
  onWidgetOpened={() => console.log('Widget opened')}
  onWidgetClosed={() => console.log('Widget closed')}
/>

Authentication ​

Pass a customer token to identify logged-in users:

tsx
<KleroFeedback
  projectSlug="myproject"
  customerToken="your-jwt-token"
/>

See the Authentication Guide for token generation.

Custom Base URL ​

For self-hosted or custom domain setups:

tsx
<KleroFeedback
  projectSlug="myproject"
  baseUrl="https://feedback.mycompany.com"
/>

Additional Embed Config ​

Pass extra configuration to the embed:

tsx
<KleroEmbed
  projectSlug="myproject"
  embedType="survey"
  embedConfig={{ surveyUlid: "01ABC123..." }}
/>

Event Hook ​

For granular event handling across multiple components, use the useKleroEvents hook:

tsx
import { useEffect } from 'react';
import { useKleroEvents } from '@kleroai/react-native';

function App() {
  const { on } = useKleroEvents();

  useEffect(() => {
    const unsubscribe = on('survey:completed', (data) => {
      console.log('Survey completed:', data.responseUlid);
    });
    return unsubscribe;
  }, [on]);
}

API Reference ​

KleroEmbed Props ​

PropTypeRequiredDescription
projectSlugstringYesYour Klero project slug
embedTypeKleroEmbedTypeYesModule type (feedback, roadmap, changelog, widget, survey)
baseUrlstringNoCustom base URL
customerTokenstringNoJWT token for user identification
embedConfigRecord<string, unknown>NoAdditional config passed to the embed
styleViewStyleNoCustom container styles
onWidgetOpened() => voidNoWidget panel opened
onWidgetClosed() => voidNoWidget panel closed
onLoad() => voidNoWebView finished loading

KleroEmbedHandle Methods ​

MethodDescription
reload()Reload the embed

KleroSurvey Props ​

PropTypeRequiredDescription
projectSlugstringYesYour Klero project slug
surveyUlidstringYesThe survey's unique identifier
baseUrlstringNoCustom base URL
customerTokenstringNoJWT token for user identification
styleViewStyleNoCustom container styles
onComplete(data: SurveyCompletedEvent) => voidNoSurvey completed
onClose(data: SurveyClosedEvent) => voidNoSurvey closed
onError(error: string) => voidNoSurvey failed to load
onLoad() => voidNoWebView finished loading

KleroSurveyHandle Methods ​

MethodDescription
open(surveyUlid?)Open the survey
close()Close the survey

Convenience Components ​

ComponentEquivalent
KleroFeedback<KleroEmbed embedType="feedback" />
KleroRoadmap<KleroEmbed embedType="roadmap" />
KleroChangelog<KleroEmbed embedType="changelog" />
KleroWidget<KleroEmbed embedType="widget" />

Customer Feedback Management