Onboarding Component

OnBoarding component is a versatile React Native component designed for creating interactive onboarding experiences. It allows you to guide users through a series of screens, collect their responses.

Components Visuals

To unlock early access to the component Get Access

Installation

To install the Quest react-native-sdk into your project, follow these steps:

  • Open your terminal/command prompt.

  • Navigate to your project's root directory using the cd command if you're not already there.

  • Run the following command to install the quest-sdk package using npm:

npm install @questlabs/react-native-sdk

This command will download and install the package and its dependencies into your project.

Make sure your project has npm and Node.js installed, and that you have the necessary permissions to install packages in your project directory.

Usage

Root Component

  • Import the QuestProvider Component: Import the QuestProvider component from the @questlabs/react-sdk package.

import { QuestProvider } from '@questlabs/react-sdk';
  • Pass the Required Props: Pass the required props to the QuestProvider. The required props are apiKey, entityId, authenticationToken and fontFamily.

To load external fonts, please refer this doc to setup expo-font on your expo app.

Component Usage

To integrate the Onboarding component into your React native application, follow these steps.

  • Import useOnboarding Hook: Import the useOnboarding component from the @questlabs/react-sdk package.

  • Import the Onboarding Component: Import the Onboarding component from the @questlabs/react-sdk package.

  • Pass the Required Props: Pass the required props to the useOnboarding . The required props are questId, questUserId, and userToken or if user don't have quest User id then they can pass own userId to get questUserId and Token.

import { useOnboarding, Onboarding } from "@questlabs/react-native-sdk";

Don't not use QuestProvider and useOnboarding Hook in same file.

Props of Onboarding Component

The Onboarding component accepts the following props

Styles Props

styleConfig {
  Form?: ViewStyle;
  Topbar?: ViewStyle;
  Heading?: TextStyle;
  Description?: TextStyle;
  Input?: ViewStyle;
  Label?: TextStyle;
  PrimaryButton?: ViewStyle | TextStyle;
  SecondaryButton?: ViewStyle | TextStyle;
  MultiChoice?: {
    style?: TextStyle;
    selectedStyle?: ViewStyle;
  };
  Footer?: {
    FooterStyle?: ViewStyle;
    FooterText?: TextStyle;
    FooterIcon?: TextStyle;
  };
}

Example Usage

App.js

import { SafeAreaView, StyleSheet, StatusBar } from "react-native";
import React, { useState } from "react";
import { QuestProvider } from "@questlabs/react-native-sdk";
import DemoComponent from "./DemoComponent";

export default function App() {
return (
    <SafeAreaView style={styles.container}>
      <StatusBar />
      <QuestProvider
        apiKey="Your-Api-Key"
        apiSecret="Your-Api-Secret"
        entityId="Your-Api-entityId"
        authenticationToken="Your-authentication-token"  
        fontFamily= "Your-Font-FamFamily"
        >
        
        <DemoComponent />
        
        </QuestProvider>
   
    </SafeAreaView>
  );
}

DemoComponent.tsx

import React from "react";
import {Onboarding,useOnboarding  } from "@questlabs/react-native-sdk";
const DemoComponent = () => {
  // const onboarding = useOnboarding({
  //   questId: "Your-Quest_ID" ,
  //   userId:"5235trfet365try67ywry5"
  //   })

  const onboarding = useOnboarding ({
    questId: "Your-Quest_ID" ,
    questUserId: "Your-user-id",
    questToken: "Your-Token-id" 
    });
  return (
    <>
      <Onboarding
        styleConfig={{
          Form: {
            height: "auto",
            backgroundColor: "lightgray"
          },
          Description: { color: "yellow" },
          Footer: {
            FooterIcon: { color: "red" }
          },
          Heading: { color: "red" },
          Input: {
            backgroundColor: "orange"
          },
          Label: { color: "blue" },
          MultiChoice: {
            // style: {
            //   color: "yellow"
            // },
            // selectedStyle: {
            //   backgroundColor: "red",
            //   borderColor: "black"
            // }
          },
        }}
        template="single"
        onCross={() => console.log("out")}
        isModal={false}
        multipleChoice="fill"
        questId={onboarding.questId}
        questToken={onboarding.questToken}
        questUserId={onboarding.questUserId}
        // sections={[
        //   {
        //     name: "Details",

        //     criteriaNames: [
        //       "First name",
        //       "Last name",
        //       // "Add your address",
        //       "Email",
        //       "Gender",
        //       "Colors",

        //     ],
        //   },
        //   {
        //     name: "Company",

        //     criteriaNames: [
        //       "Company name",
        //       // "Last name",
        //       "Email",
        //       // "Gender",
        //       // "Colors",

        //     ],
        //   },
        //   {
        //     name: "Connection",

        //     criteriaNames: [
        //       "First name",
        //       "Last name",
        //       "Email",
        //       "Gender",
        //       "Colors",

        //     ],
        //   },
        // ]}
        description="THis is my Onboarding"
        title="My Onboarding"
        loading={onboarding.loading}
        sections={[
          {
            criteriaNames: [
              "First name",
              "Last name",
              "Email",
              "Gender",
              "Colors",
              "Add your address",
              "What is your company name?",
              "Your hobbies?",
              "What is your role in the company?",
            ],
          },
        ]}
        actions={[
          {
            actionId: "123",
            actionType: "USER_INPUT_TEXT",
            answer: [],
            title: "First name",
          },
          {
            actionId: "32",
            actionType: "USER_INPUT_TEXT",
            answer: [],
            title: "Last name",
          },
          {
            actionId: "342",
            actionType: "USER_INPUT_SINGLE_CHOICE",
            answer: [],
            options: [1, 2, 3, 4],
            title: "Gender",
          },
          {
            actionId: "123",
            actionType: "USER_INPUT_MULTI_CHOICE",
            answer: [],
            options: ["df5", "afg", "sdgfh", "asdg"],
            title: "Colors",
          },
          {
            actionId: "5673563",
            actionType: "USER_INPUT_TEXT",
            answer: [],
            title: "What is your company name?",
          },
        ]}
        // actions={onboarding.actions}
      />
    </>
  );
};
export default DemoComponent;

Demo

Last updated