createOnboardingApp
API reference for all Onboarding SDK methods, types, and options.Import
Parameters
The function accepts a single argument object with the following properties:| Property | Type | Description |
|---|---|---|
origin | string | The origin URL of the onboarding app |
inviteToken | string | The invite token used to authenticate and initialize the onboarding session |
mode? | 'embedded' | 'non-embedded' | undefined | The iframe mode. When set to 'embedded', the iframe is embedded in the parent site. When 'non-embedded' or undefined, the iframe operates in standalone mode |
Example
Returned Methods
ThecreateOnboardingApp function returns an object with the following methods and properties:
subscribe(callback)
Subscribes to messages from the Worth Onboarding App. Returns a subscription object with an unsubscribe method.
Parameters:
callback: (event: MessageEvent<OnboardingAppMessage>) => void- A callback function that receives message events from the Worth Onboarding App
{ unsubscribe: () => void }- A subscription object with anunsubscribemethod to stop listening to messages
ROUTE_URL- Notifies when the route changes in the onboarding appIFRAME_RESIZE- Notifies when the iframe needs to resize (includes height)IFRAME_INITIALIZED- Notifies when the iframe has finished initializingONBOARDING_STARTED- Signals that the onboarding flow is ready; the parent clears the loading state and the SDK initializes the detached iframe.STAGE_NAVIGATION- Updates as the user moves through stage. With this event that the parent receives it, updates navigation, and re-renders the buttons and labels accordingly. See more details about how this message type is handled.ERROR- Handles ERROR events from the onboarding SDK subscription. See more details about how this message type is handled.
Handling STAGE_NAVIGATION message type
Drives navigation actions, and the SDK app responds with the new navigation state and stage metadata.Field‑by‑field semantics
- isInitialStage: true when the current stage is the very first step of the flow. The parent uses this to decide that “Back” should leave the flow entirely instead of going to a previous stage.
- isLastStage: true when the current stage is the final step. The parent uses this to change both behavior (navigate to a “completed” route instead of NEXT_STAGE) and label (“Complete” vs “Next”).
- stage: A logical identifier for the current stage (e.g. “personal-info”, “documents”, etc.). In your parent UI it’s currently just displayed for observability / debugging.
- nextStatus: controls the Next/Complete button
- visible: whether the Next/Complete button should be rendered at all.
- disabled: whether the button is clickable (e.g. when validation not satisfied).
- loading: whether the action is in progress (you could map this to a spinner on the button if desired).
- isSubmit: the child is telling you “this click actually submits data / form”, even if it’s not the very last stage. You could use this to show different copy or confirmation.
- prevStatus: controls the Back button Same idea: visible, disabled, loading communicate whether Back should be shown and usable.
- skipStatus: controls the Skip button Same structure:*** visible, disabled, loading, telling you whether skipping is allowed on this particular stage.
Handling ERROR message type
Extracts the error message and displays it via notification UI component.setMode(mode)
Sets the iframe mode to control how the onboarding app is displayed. Sends a SET_IFRAME_MODE message to the Worth Onboarding App.
Parameters:
mode: 'embedded' | 'non-embedded' | undefined- The mode to set'embedded'- The iframe is embedded within the parent site’s layout'non-embedded'- The iframe is displayed in standalone modeundefined- Uses as defaultnon-embeddedmode
void
Example:
next()
Navigates the onboarding app to the next stage. Sends a NEXT_STAGE message to the Worth Onboarding App.
Parameters: None
Returns: void
Example:
prev()
Navigates the onboarding app to the previous stage. Sends a PREV_STAGE message to the Worth Onboarding App.
Parameters: None
Returns: void
Example:
skip()
Skips the current onboarding app stage. Sends a SKIP_STAGE message to the Worth Onboarding App.
Parameters: None
Returns: void
Example:
setCustomCss(css)
Injects custom CSS styles into the Worth Onboarding App iframe. Sends a SET_CUSTOM_CSS message to the Worth Onboarding App.
Parameters:
css: string- A string containing CSS rules to apply to the Worth Onboarding App
void
Example:
refreshSize()
Requests the Worth Onboarding App to recalculate and report its size. This is useful when the iframe content changes dynamically. Sends a REFRESH_SIZE message to the Worth Onboarding App.
Parameters: None
Returns: void
Example:
iframe
A read-only property that contains the Worth Onboarding App. This is the actual iframe DOM element that should be appended to your page.
Type: HTMLIFrameElement
Example: