Onboarding Widget - Integration Best Practices

1. Use a responsive container and automatic height

This page explains how to embed the Hosted Online Onboarding widget reliably in your website or application. It covers layout, initialization, session handling, theming, browser permissions, callbacks, and pre-release testing.

It assumes you have completed the Quick-start in Hosted Online Onboarding and that your backend can obtain an onboarding URL for each user. The examples use widget version 1.3.1. Pin a published version in production and review the release notes before upgrading.

The hosted onboarding widget takes care of the layout for you:

  • Handles the responsive layout inside its iframe
  • Fills the available container width
  • Adjusts its height to fit its content
  • Requires no additional widget-specific stylesheet for a standard integration

Your site determines where the container is placed and how much room it gets. Keep your current responsive layout. On small screens, you may want to stack the surrounding content so onboarding has the full width available.

Insert this markup into your page:

<section aria-label="Secure onboarding">
  <div id="lemonway-widget"></div>
  <p id="onboarding-feedback" role="status" aria-live="polite" hidden></p>
</section>
TopicGuidance
Container heightLeave the container's height unset so the widget can resize with its content. Do not override the iframe's height with CSS.
ScrollingPrefer scrolling the host page for an inline integration. Avoid additional height limits or clipping on ancestors that prevent users from reaching the bottom of the widget.
Flex or grid overflowIf a flex or grid item in your website refuses to shrink and causes overflow, check its sizing rules. min-width: 0 on that item may be appropriate. This is a host-layout adjustment, not a required widget style.
ResizingDo not add your own height polling, viewport-based resizing, or extra padding through onHeightChange. Automatic resizing already handles content changes.
Fixed-height panelsIf your design requires a fixed-height modal or panel, set its height deliberately and test scrolling and keyboard access inside it. Fixed heights are supported, but an 800px height is not a general requirement or a mobile default.
Width testingTest using the widget's actual width inside your layout. A large browser window can still contain a narrow widget.

If content inside the onboarding frame is incorrectly positioned or clipped, report it to Lemonway with the affected step and dimensions. Do not compensate for an internal layout defect by injecting styles into the iframe.

2. Initialize once and provide loading feedback

Obtain the onboarding URL through your backend. Keep API credentials on the server. Replace YOUR_ONBOARDING_URL below at runtime with the URL for the current user's journey.

Place this code after the container markup, or run it once the script has loaded and the container exists:

<script src="https://hosted-onboarding.lemonway.com/widget/1.3.1.min.js"></script>
<script>
  const feedback = document.getElementById('onboarding-feedback');

  LemonwayWidget.init('YOUR_ONBOARDING_URL', 'lemonway-widget', {
    lang: 'en',
    isSidebarMenuEnabled: false,
    loadingText: 'Loading your secure onboarding…',
    errorText: 'Loading is taking longer than expected. Check your connection or contact support.',
    loadTimeout: 20000,
    onReady: () => {
      feedback.hidden = true;
    },
    onError: (error) => {
      console.warn('Onboarding widget error', {
        code: error.code,
        widgetVersion: LemonwayWidget.version
      });

      if (error.code === 'LOAD_TIMEOUT') return;

      feedback.textContent =
        error.code === 'INVALID_LINK' || error.code === 'SESSION_EXPIRED'
          ? 'Your onboarding link or session is no longer valid. Return to your account to restart onboarding.'
          : 'Onboarding could not continue. Please contact support.';
      feedback.hidden = false;
    }
  });
</script>

Note

Pin an exact widget version in production. Before upgrading, review the release notes and test the new version in a sandbox environment. Pinning the widget does not freeze the hosted onboarding application, so retest your integration when Lemonway announces changes to the hosted journey.

Adapt the recovery message to your website and provide a working route back to the user's account or your support service. Also handle failure to download the widget script in your application's loading UI: widget callbacks cannot run if the script itself has not loaded.

loadTimeout is expressed in milliseconds; 20000 is an example, not a required value. No readiness timeout is enabled by default. The timeout message uses errorText when loadingText is configured, and a later readiness notification clears it.

The readiness timeout covers the initial application load. It does not monitor every subsequent step, detect every Onfido error, or prove that camera access works.

Pass supported settings through the JavaScript options object. For example, use isSidebarMenuEnabled: false to hide the sidebar. The widget adds the embedding parameters itself; partners do not need to append them manually widget, parentOriginor a duplicate sidebar setting to the URL.

3. Preserve the session throughout the journey

PracticeRequirement
Script loadingLoad the widget script once and initialize one instance per container.
Container lifecycleKeep the container mounted while the user completes onboarding. Do not recreate it after ordinary state changes, step changes, or device rotation.
CleanupCall destroy when the user leaves the page, or the component unmounts. Calling init again on an existing instance does not replace its URL or configuration.
Onboarding URLsTreat onboarding URLs as sensitive, single-use entry links. Do not open one in another tab to check it before embedding it, or automatically reload it after a timeout.
Replacement linksFor INVALID_LINK or SESSION_EXPIRED, use your backend's supported flow to obtain a replacement URL. Destroy the previous widget before initializing it with the replacement. The widget cannot generate a new link itself.

For applications using a bundler, install the package instead of injecting another CDN script:

npm install --save-exact @lemonway/[email protected]

In React or Next.js, initialize in a client-side effect and clean up the same DOM element:

'use client';

import { useEffect, useRef } from 'react';
import { init, destroy } from '@lemonway/onboarding-widget';

export default function OnboardingWidget({ onboardingUrl }) {
  const container = useRef(null);

  useEffect(() => {
    const target = container.current;
    if (!target || !onboardingUrl) return;

    init(onboardingUrl, target, { lang: 'en', isSidebarMenuEnabled: false });

    return () => {
      destroy(target);
    };
  }, [onboardingUrl]);

  return <div ref={container} />;
}

In Vue 3 or Nuxt, initialize after mounting and destroy before unmounting:

<template>
  <div ref="container"></div>
</template>

<script setup>
import { ref, onMounted, onBeforeUnmount } from 'vue';
import { init, destroy } from '@lemonway/onboarding-widget';

const props = defineProps({ onboardingUrl: { type: String, required: true } });
const container = ref(null);

onMounted(() => {
  if (container.value) {
    init(props.onboardingUrl, container.value, {
      lang: 'en',
      isSidebarMenuEnabled: false
    });
  }
});

onBeforeUnmount(() => {
  if (container.value) destroy(container.value);
});
</script>

Mount these components after you get the URL, and keep it stable during the journey. The Vue example assumes the URL does not change while mounted. Add the loading options and error handling from the preceding example to suit your application. The same lifecycle rule applies to other frameworks: initialize in the browser after mounting and destroy on cleanup.

4. Customize through the supported theme

The onboarding journey runs in an iframe. Fonts, styles, and backgrounds from the host website do not automatically apply inside it.

Use theme in the initialization options for supported colors, typography, buttons, forms, and cards. Use host CSS for the surrounding page. Do not inject CSS into the onboarding or Onfido frames, change their internal elements, or replace the iframe created by the widget.

For typography, use available Google Fonts, Fontshare fonts with fontProvider: 'fontshare', or system fonts, and include a fallback family. Naming a font loaded only by your website does not make it available inside the iframe. Custom font URLs and a global transparent-background option are not supported by the current widget theme. Identity verification content uses its own typography and may differ from the surrounding onboarding pages.

5. Check browser permissions and embedding policies

Serve the integration over HTTPS. The widget configures its iframe permissions for identity verification; users must still grant any permissions requested by their browser.

If your website adds another iframe around the widget, every embedding layer must allow the required features. A restrictive Permissions-Policy header can block them even when the widget iframe has the correct allow attribute. Check your Content Security Policy too: the host must allow the widget script and the onboarding frame from their actual origins. Apply least-privilege allowlists appropriate to your deployment rather than disabling these protections globally.

6. Understand how callbacks are interpreted

CallbackMeaning
onReadyThe onboarding application reports readiness. This is not identity approval or confirmation that every later step will load.
onPageChangeA page change occurred inside the widget. This callback does not provide a step name or a completion result.
onFinishThe user clicked the finish action on the pending-verification page. This is a user-interface event, not a KYC approval notification.
onMyAccountThe user requested a return to their account. Your website handles the navigation.
onErrorThe widget reported an initialization, readiness, link, session, or application error. Not every internal identity-provider error is forwarded through this callback.

Use the supported backend status or notification mechanism to determine the actual onboarding and verification outcome.

7. Validate the complete integration and collect useful evidence

Before release, test on your own host page in a non-production environment:

  • Narrow widths, including 320, 375, and 390 CSS pixels, plus tablet and desktop layouts. These are test cases, not a guaranteed minimum-width specification.
  • Portrait and landscape on real iOS Safari and Android Chrome devices, in addition to browser emulation.
  • The identity verification screen, the secure-link button, and the subsequent camera or cross-device flow using approved test journeys.
  • Long-form content, validation errors, the mobile keyboard, keyboard navigation, and browser zoom. Check that buttons stay reachable and host headers, footers, or cookie banners do not cover them.
  • Slow loading, blocked requests, expired links and sessions, leaving the page, and returning to the journey. Confirm that users receive feedback and a working recovery action.
  • Any fixed-height panel or modal, including scrolling to the final action in each step.

If a widget appears blank, first determine whether the whole onboarding frame is missing or only the identity verification content. Check browser console and network errors. A blank cross-origin iframe in a session replay is not sufficient evidence that it was blank for the user; confirm with a direct observation or screenshot.

For support, provide the timestamp and time zone, onboarding identifier, widget version, browser and OS versions, actual widget dimensions, failing step, and relevant error codes or failed request origins/statuses. Share screenshots with personal information removed. Do not include the full onboarding entry URL, authentication tokens, or identity documents in ordinary logs or screenshots.