SDK reference · React Native SDK / React Native Common Implementation Patterns

Configure Flows Locally and Run Step by Step

Use the Sections API when your app needs custom screens or business logic between SDK modules. You create an onboarding session, split the flow into sections, and run each section with startOnboardingSection(). Control returns to your host application between sections, so you can show your own screens, make decisions, or call your backend before continuing.

Use this pattern when the default flow approach does not give you enough control - for example, when you need to interleave your own UI between capture steps, or group modules into logical sections.

Before you start

Make sure the SDK is installed and initialized. See Getting Started for setup and initialization.

The common path is four steps: set up the onboarding session, register step listeners if you want per-step results, configure and start each section, and finish the session when all sections are complete.

Set up an onboarding session

sessionConfig is optional for setupOnboardingSession(). If you don't need to customize the session, you can omit it.

❗{/* [SME input needed: source-level review confirmed that an empty or omitted sessionConfig is valid (every field is optional), but per-field default values are not documented anywhere in the SDK. Confirm defaults for each field so customers know what they're getting when they omit it. Escalation candidate: needs product/SDK-team knowledge.] */}

const session = await IncodeSdk.setupOnboardingSession({
  sessionConfig: {
    externalId: 'external-id',
  },
});

console.log(session.interviewId, session.token);

Useful sessionConfig fields include:

Field Use
queue Assign the session to a queue.
interviewId / token Start from a backend-created session, or resume an existing session (see below).
configurationId Apply a Dashboard flow configuration.
externalId / externalCustomerId Link the Incode session to your own user/customer ID.
validationModules Select server-side validation modules.
customFields Attach custom string data.
e2eEncryptionEnabled Enable E2EE for the session. See End-to-End Encryption for the full setup.
mergeSessionRecordings Merge ID and Face recordings.
voiceConsentLanguage Set VideoSelfie voice consent language: en, es, pt, or he.

Available validation modules:

  • id
  • liveness
  • faceRecognition
  • governmentValidation
  • governmentFaceValidation
  • governmentOcrValidation
  • videoSelfie

Default validation modules are id, liveness, and faceRecognition.

Resume an existing onboarding session

To continue an existing onboarding session (for example, one created by your backend), pass the existing token or interviewId to setupOnboardingSession():

const session = await IncodeSdk.setupOnboardingSession({
  sessionConfig: {
    token: 'YOUR_TOKEN',
  },
});

Register step listeners

If you want to react to individual modules as they complete, register listeners before starting any sections. If you only need section-level outcomes, you can rely on the value returned by startOnboardingSection() and skip this step.

const unsubscribers = [
  IncodeSdk.onSessionCreated((session) => {
    console.log(session.interviewId);
  }),
  IncodeSdk.onStepCompleted({
    module: 'IdScanFront',
    listener: (event) => console.log(event.result),
  }),
  IncodeSdk.onStepCompleted({
    module: 'IdScanBack',
    listener: (event) => console.log(event.result),
  }),
  IncodeSdk.onStepCompleted({
    module: 'ProcessId',
    listener: (event) => console.log(event.result.extendedOcrData),
  }),
  IncodeSdk.onStepCompleted({
    module: 'SelfieScan',
    listener: (event) => console.log(event.result),
  }),
  IncodeSdk.onStepCompleted({
    module: 'FaceMatch',
    listener: (event) => console.log(event.result),
  }),
];

Call each unsubscriber when the screen unmounts:

React.useEffect(() => {
  const unsubscribers = setupListeners();

  return () => {
    unsubscribers.forEach((unsubscriber) => unsubscriber());
  };
}, []);

For the shape and fields of each result object passed to these listeners, see Results.

Configure section flow

const idSectionConfig = {
  sectionTag: 'idSection',
  flowConfig: [{ module: 'IdScan' }],
};

startOnboardingSection accepts the same flowConfig shape and modules as startOnboarding. See Modules for the catalog and per-module configuration parameters.

Some modules depend on the output of other modules and must appear after them in the flowConfig array:

  • FaceMatch should follow IdScan and SelfieScan.
  • ProcessId should follow IdScanFront and IdScanBack.
  • VideoSelfie should follow IdScan (in faceMatch mode) or SelfieScan (in selfieMatch mode).
  • Aes should follow Phone, IdScan, and SelfieScan.
  • UserScore and Approve should be at the end.

❗{/* [SME input needed: source-level review couldn't confirm whether module dependencies (like FaceMatch requiring IdScan and SelfieScan to have run) work across sections, or only within a single section. Confirm expected behavior. Escalation candidate: needs product/SDK-team knowledge or native-side testing.] */}

Start onboarding section

startOnboardingSection() resolves with a result indicating whether the section succeeded (status is success or userCancelled). Use the result to decide what to do next, including running your own logic before starting the next section.

const idSection = await IncodeSdk.startOnboardingSection(idSectionConfig);

if (idSection.status === 'success') {
  await IncodeSdk.startOnboardingSection({
    sectionTag: 'selfieSection',
    flowConfig: [{ module: 'SelfieScan' }],
  });
}

You can start multiple sections, but only one at a time. Wait for each startOnboardingSection() call to resolve before starting the next.

Optionally, specify sectionTag to uniquely identify the section; use it to distinguish sections in listener events or logs.

Finish onboarding session

await IncodeSdk.finishOnboardingFlow();

❗{/* [SME input needed: source-level review confirmed the rule that UserScore and Approve must go last in a flow, but couldn't confirm whether Conference has a similar ordering constraint (i.e., must finishOnboardingFlow() be called before or after a Conference module runs?). Confirm expected sequencing. Escalation candidate: needs product/SDK-team knowledge.] */}

To clean up local user data generated during the session, call deleteLocalUserData(). See Delete Local Session Data for details.


Was this page helpful?