Prerequisites
Before you start, ensure that you have:- A valid invite token for the customer or applicant who is to be onboarded
- Node.js and npm installed in your project
1
Install the SDK
Install the SDK package via npm:
2
Add a mount target
Add an empty element to your page wherein the onboarding flow should render. SDK 3 mounts directly into this element
3
Create the onboarding instance
Call Use
createWorthOnboarding with your invite token and lifecycle callbacks:apiBaseUrl only if you’re targeting a non-production or non-default Worth API environment:4
Mount the SDK
mount() is asynchronous and accepts either a CSS selector string or an HTMLElement. It resolves once the onboarding flow has rendered into the targetmount() returns a promise, wrap it in a try/catch if you want to handle mount-time failures separately from runtime errors reported through onError5
Clean up on unmount
Call
unmount() when the containing route or component unloads. SDK 3 supports only one mounted instance at a time, so unmounting is required before mounting a new instance on the same pagePutting It Together
Using SDK 3 in a Framework
The example above is illustrative vanilla TypeScript. In component-based frameworks like React, create the instance once, mount it when the component mounts, and unmount it in your cleanup function:Content Security Policy
SDK 3 injects its scoped runtime styles automatically duringmount(). If your host page enforces a strict style-src Content Security Policy, pass your page’s request-level nonce with styleNonce:
Handling Errors
onError receives a WorthOnboardingError, which includes a code that you can branch on. See Error Handling for a complete list of error codes.
Next Steps
- See API Reference for complete API documentation
- Migrating from SDK 2? Read the Migration Guide