createOnboardingApp
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 initializing
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:
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:
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: