Skip to main content

OnboardingFlow

Guided flow for admins to onboard a contractor to the company.

Remarks

Renders a multi-step experience that collects every piece of information required to add a contractor to a company. Begins on the contractor list and transitions into the per-step screens when "Add contractor" or a row's "Edit"/"Continue" action is invoked; the submit step returns to the list. The flow is driven by an internal state machine and wraps each step in error and suspense boundaries.

Each step of the flow is also exported as a standalone block (see the Blocks table) for composing a custom workflow when this orchestration is the wrong fit.

The flow forwards every event emitted by its blocks to onEvent; see the events table on each block for the full set of events and payloads observable from this flow.

Example

App.tsx
import { ContractorOnboarding, type EventType } from '@gusto/embedded-react-sdk'

function MyApp() {
return (
<ContractorOnboarding.OnboardingFlow
companyId="a007e1ab-3595-43c2-ab4b-af7a5af2e365"
onEvent={(eventType: EventType) => {
if (eventType === 'contractor/submit/done') {
// Contractor onboarding complete — navigate to your next screen
}
}}
/>
)
}

OnboardingFlowProps

Props for OnboardingFlow.

PropertyTypeDescription
companyIdstringThe associated company identifier.
onEventOnEventType<EventType, unknown>Callback invoked each time the component emits an event — user interactions, successful API responses, step transitions, or errors. Receives the event type constant and an optional payload whose shape varies by event. See the Event Handling guide and each component's event table for the full list of emitted events.
defaultValues?RequireAtLeastOne<OnboardingFlowDefaultValues>Default values for individual flow step components — profile and/or address sub-objects.

Inherits children, className, dictionary, FallbackComponent, LoaderComponent from BaseComponentInterface.

Events

EventDescriptionData
contractor/createFired when the user chooses to add a new contractor
contractor/updateFired when the user selects a contractor to edit{ contractorId: string }
contractor/deletedFired when a contractor is deleted{ contractorId: string }
contractor/onboarding/continueFired when the user chooses to continue onboarding a contractor
contractor/createdFired when a new contractor is created successfullyCreate contractor API response
contractor/updatedFired when an existing contractor is updatedUpdate contractor API response
contractor/profile/doneFired when the contractor profile step is complete{ contractorId: string, onboardingStatus?: string, selfOnboarding: boolean }
contractor/address/updatedFired when the contractor address is updatedCreate or update contractor address API response
contractor/address/doneFired when the address step is complete
contractor/bankAccount/createdFired when a bank account is created for the contractorCreate contractor bank account API response
contractor/paymentMethod/updatedFired when the payment method is updatedUpdate contractor payment method API response
contractor/paymentMethod/doneFired when the payment method step is complete
contractor/newHireReport/updatedFired when the new hire report is updatedUpdate contractor API response
contractor/newHireReport/doneFired when the new hire report step is complete
contractor/onboardingStatus/updatedFired when the contractor's onboarding status is updatedChange contractor onboarding status API response
contractor/submit/doneFired when the contractor submission is complete{ message: string } or { onboardingStatus, message: string }
contractor/invite/selfOnboardingFired when the contractor is invited for self-onboarding{ contractorId: string }

Sub-components

ComponentDescription
ContractorListLists a company's contractors with controls to add, edit, delete, cancel self-onboarding, and continue onboarding.
ContractorProfileForm for creating or editing a contractor profile, supporting both individual and business contractor types.
AddressForm for collecting and updating a contractor's mailing address. Renders a business or home address title based on the contractor type.
PaymentMethodManages a contractor's payment method, capturing a bank account for direct deposit or recording check as the payment method.
NewHireReportCollects new hire reporting information for a contractor and persists it to the contractor record.
ContractorSubmitFinalizes contractor onboarding by updating the onboarding status, and in the self-onboarding flow can trigger an invitation to the contractor.

Step flow

OnboardingFlow begins on the contractor list and steps through the per-step screens once "Add contractor" or a row's "Edit"/"Continue" action is invoked. After the profile step, the path branches on whether the contractor self-onboards:

  • Admin onboarding (selfOnboarding = false) — the admin completes every step, including address and payment method.
  • Self-onboarding (selfOnboarding = true) — the admin sets up the basics and the contractor completes their own address and payment method later, so those two steps are skipped here.

The new hire report step appears only on the contractor's initial onboarding pass (while its onboarding status is admin_onboarding_incomplete or self_onboarding_not_invited). Once the contractor has advanced past that — to admin review, an active self-onboarding stage, or completion — the step is skipped and the flow goes straight to submit. The flow derives this from the contractor's onboardingStatus, which it reads off the onboardingStatus carried on contractor/profile/done.

The progress bar's secondary button emits CANCEL from any step, returning to the list.

Endpoints