Skip to main content

API Reference

Complete API documentation for all exported components, hooks, and types.

Components

OnboardingProvider

The root provider component that wraps your app and provides onboarding context for data fetching.

import { OnboardingProvider } from "@rocapine/react-native-onboarding";

<OnboardingProvider
client={client}
locale="en"
customAudienceParams={{ onboardingId: "abc-123" }}
>
<YourApp />
</OnboardingProvider>

Props

PropTypeDefaultDescription
clientOnboardingStudioClientRequiredClient instance for API communication
localestring"en"Locale for fetching steps
customAudienceParamsRecord<string, any>{}Additional parameters for API

ThemeProvider

The theme provider component that wraps your app and provides theme context. Import from the UI SDK.

import { ThemeProvider } from "@rocapine/react-native-onboarding-ui";

<ThemeProvider
initialColorScheme="light"
customTheme={{
colors: { primary: "#FF5733" },
typography: {
fontFamily: { title: "Poppins-Bold" }
}
}}
>
<YourApp />
</ThemeProvider>

Props

PropTypeDefaultDescription
initialColorScheme"light" | "dark""light"Initial color scheme
customThemeDeepPartial<Theme>-Custom theme to override both light and dark mode tokens
customLightThemeDeepPartial<Theme>-Custom theme tokens for light mode only
customDarkThemeDeepPartial<Theme>-Custom theme tokens for dark mode only

OnboardingPage

Central routing component that renders the appropriate page based on step type.

<OnboardingPage
step={step}
onContinue={handleContinue}
theme={theme}
customComponents={customComponents}
/>

Props

PropTypeDescription
stepOnboardingStepTypeStep data to render
onContinue(args?: any) => voidCallback when user continues
themeThemeOptional theme override (defaults to theme from ThemeProvider)
customComponentsCustomComponentsCustom components for the onboarding
isSandboxbooleanEnable sandbox mode for development

ProgressBar

Global progress indicator component. Add once in your app layout, typically inside both providers.

<OnboardingProvider {...props}>
<ThemeProvider>
<ProgressBar isProgressBarVisible={isProgressBarVisible} progressPercentage={progressPercentage} />
<YourApp />
</ThemeProvider>
</OnboardingProvider>

Props

None. Reads from progress context automatically.


Page Renderers

Individual renderer components for each page type.

import {
QuestionRenderer,
MediaContentRenderer,
CarouselRenderer,
PickerRenderer,
LoaderRenderer,
RatingsRenderer,
CommitmentRenderer,
} from "@rocapine/react-native-onboarding";

Common Props:

PropTypeDescription
stepStepTypeType-specific step data
onContinue(args?: any) => voidCallback when user continues

Example:

<MediaContentRenderer
step={mediaContentStep}
onContinue={(args) => console.log(args)}
/>

Hooks

useOnboardingQuestions

Hook for accessing onboarding steps in your pages.

import { useOnboardingQuestions } from "@rocapine/react-native-onboarding";

const {
step,
isLastStep,
stepsLength,
onboardingMetadata,
steps
} = useOnboardingQuestions({
stepNumber: 1,
});

Parameters

ParamTypeDescription
stepNumbernumberThe current step number (1-indexed)

Returns

PropertyTypeDescription
stepOnboardingStepTypeCurrent step data
isLastStepbooleanTrue if this is the last step
stepsLengthnumberTotal number of steps
onboardingMetadataOnboardingStepMetadataMetadata from API (id, name, audienceId, etc.)
stepsOnboardingStepType[]Array of all steps

useTheme

Hook for accessing theme tokens and utilities. Import from the UI SDK.

import { useTheme } from "@rocapine/react-native-onboarding-ui";

const { theme, colorScheme, toggleTheme } = useTheme();

Returns

PropertyTypeDescription
themeThemeCurrent theme tokens (colors + typography)
colorScheme"light" | "dark"Current color scheme
toggleTheme() => voidFunction to toggle between light and dark mode

useCustomComponents

Hook for accessing custom component overrides.

import { useCustomComponents } from "@rocapine/react-native-onboarding";

const customComponents = useCustomComponents();
const Button = customComponents.QuestionAnswerButton || DefaultButton;

Returns

PropertyTypeDescription
customComponentsCustomComponentsCustom component overrides

Classes

OnboardingStudioClient

Client for communicating with the Rocapine CMS backend.

import { OnboardingStudioClient } from "@rocapine/react-native-onboarding";

const client = new OnboardingStudioClient(projectId, options);

Constructor

new OnboardingStudioClient(
projectId: string,
options?: {
appVersion?: string;
isSandbox?: boolean;
platform?: "ios" | "android";
}
)

Parameters

ParamTypeDefaultDescription
projectIdstringRequiredYour Rocapine project ID
options.appVersionstring-Your app version
options.isSandboxbooleanfalseEnable sandbox mode
options.platform"ios" | "android"Auto-detectedPlatform identifier

Methods

getSteps(params)

Fetches onboarding steps from the CMS.

const { steps, headers } = await client.getSteps({
locale: "en",
onboardingId: "abc-123",
});

Utilities

getTextStyle

Utility function to get semantic text styles from theme.

import { getTextStyle } from "@rocapine/react-native-onboarding";

const textStyle = getTextStyle(theme, "heading1");

Parameters

ParamTypeDescription
themeThemeTheme object from useTheme()
styleNameTextStyleNameName of the semantic style

TextStyleName Options

  • heading1 - Large headings (32px, semibold)
  • heading2 - Medium headings (24px, semibold)
  • heading3 - Small headings (18px, medium)
  • body - Body text (16px, regular)
  • bodyMedium - Medium body text (16px, medium)
  • label - Labels (14px, medium)
  • caption - Captions (12px, regular)
  • button - Button text (16px, medium)

Returns

{
fontSize: number;
fontWeight: string;
lineHeight: number;
fontFamily?: string;
}

Types

OnboardingStepType

Union type of all step types:

type OnboardingStepType =
| QuestionStepType
| MediaContentStepType
| CarouselStepType
| PickerStepType
| LoaderStepType
| RatingsStepType
| CommitmentStepType;

OnboardingStepMetadata

Metadata returned from the API containing information about the onboarding flow:

interface OnboardingStepMetadata {
id: string;
name?: string;
audienceId?: string;
audienceName?: string;
audienceOrder?: number;
locale?: string;
draft?: boolean;
}
PropertyTypeDescription
idstringUnique onboarding ID
namestring?Display name of the onboarding
audienceIdstring?Targeted audience ID
audienceNamestring?Targeted audience name
audienceOrdernumber?Audience priority order
localestring?Locale of the onboarding
draftboolean?Whether this is a draft version

ThemeTokens

Partial theme override type:

interface ThemeTokens {
colors?: {
primary?: string;
secondary?: string;
disable?: string;
tertiary?: {
tertiary1?: string;
tertiary2?: string;
tertiary3?: string;
};
neutral?: {
highest?: string;
higher?: string;
high?: string;
medium?: string;
low?: string;
lower?: string;
lowest?: string;
};
surface?: {
lowest?: string;
lower?: string;
low?: string;
medium?: string;
high?: string;
higher?: string;
highest?: string;
opposite?: string;
};
text?: {
primary?: string;
secondary?: string;
tertiary?: string;
opposite?: string;
disable?: string;
};
};
typography?: {
fontFamily?: {
title?: string;
text?: string;
tagline?: string;
};
fontSize?: {
xs?: number;
sm?: number;
md?: number;
lg?: number;
xl?: number;
"2xl"?: number;
"3xl"?: number;
"4xl"?: number;
};
fontWeight?: {
regular?: string;
medium?: string;
semibold?: string;
bold?: string;
extrabold?: string;
};
lineHeight?: {
tight?: number;
normal?: number;
relaxed?: number;
};
textStyles?: {
heading1?: TextStyle;
heading2?: TextStyle;
heading3?: TextStyle;
body?: TextStyle;
bodyMedium?: TextStyle;
label?: TextStyle;
caption?: TextStyle;
button?: TextStyle;
};
};
}

CustomComponents

Custom component overrides interface:

interface CustomComponents {
QuestionAnswerButton?: React.ComponentType<QuestionAnswerButtonProps>;
QuestionAnswersList?: React.ComponentType<QuestionAnswersListProps>;
}

Component Props Interfaces

QuestionAnswerButtonProps

interface QuestionAnswerButtonProps {
answer: { label: string; value: string };
selected: boolean;
onPress: () => void;
theme: Theme;
index: number;
isFirst: boolean;
isLast: boolean;
}

QuestionAnswersListProps

interface QuestionAnswersListProps {
answers: Array<{ label: string; value: string }>;
selected: Record<string, boolean>;
onAnswerPress: (value: string) => void;
multipleAnswer: boolean;
theme: Theme;
}

Default Exports

Export default components for composition:

import {
DefaultQuestionAnswerButton,
DefaultQuestionAnswersList,
} from "@rocapine/react-native-onboarding";

These allow you to wrap or extend the default implementations while maintaining the base styling.


Type Guards

isQuestionStep

import { isQuestionStep } from "@rocapine/react-native-onboarding";

if (isQuestionStep(step)) {
// TypeScript knows this is QuestionStepType
console.log(step.payload.answers);
}

Similar type guards exist for all step types.


Next Steps