@get-asset/sdk

AccountsConnect

Headless compound for connecting a new institution. It models the two steps of the flow — a default state listing the connection methods (Plaid opens Plaid Link via the Asset API; any other methods you add fire onSelectMethod), and a confirm state exposing the connected accounts so you can assign each as business or personal before linking. Built on the PlaidLink engine.

Anatomy

Import the primitive and compose the parts you need.

<AccountsConnect.Root onConnected={refetch} onSelectMethod={open}>
<AccountsConnect.Default>
<AccountsConnect.Methods>
<AccountsConnect.MethodTrigger>
<AccountsConnect.MethodTitle />
<AccountsConnect.Recommended>Recommended</AccountsConnect.Recommended>
<AccountsConnect.MethodDescription />
</AccountsConnect.MethodTrigger>
</AccountsConnect.Methods>
</AccountsConnect.Default>
<AccountsConnect.Confirm>
{/* read useAccountsConnect().pending and build the
business/personal form, then call linkInstitutions(accounts) */}
</AccountsConnect.Confirm>
</AccountsConnect.Root>

Required scopes

The access token used by AssetProvider must include these scopes for this primitive to fetch data successfully:

  • plaid:create
  • plaid:read
  • ledger:read
  • transaction:create

API reference

Root props

PropTypeDefaultDescription
onConnected(institutions, account) => voidCalled after the accounts are linked on the Asset API.
onCreated() => voidCalled after a manual account is successfully created.
onError(error) => voidCalled if creating the link token or linking fails.
onSelectMethod(method) => voidCalled when a method other than the built-in plaid / manual flows (gusto / quickbooks) is selected.
methodsConnectionMethod[]Override the connection methods shown. Defaults to Plaid + Manual. Plaid opens Plaid Link and Manual opens the inline create-account form; Gusto / QuickBooks can be added here and surface via onSelectMethod.
onExit / onEventPlaidLink callbacksForwarded to Plaid Link.
initialPendingPlaidInstitutionAccount | nullSeed the confirm state (testing/storybook).
state"loading" | "error"Force a specific state for testing.
childrenrequiredReactNodeCompound parts.

Parts

Default

Renders while choosing a connection method.

PartDescription
AccountsConnect.DefaultState wrapper. Compose the method list inside.
AccountsConnect.MethodsIterates each connection method, providing a method context.
AccountsConnect.MethodTrigger
asChild?
Button that selects the current method — Plaid opens Plaid Link, others fire onSelectMethod. Sets data-method and disables the Plaid card while loading.
AccountsConnect.MethodTitle
asChild?
Renders the method's title.
AccountsConnect.MethodDescription
asChild?
Renders the method's description.
AccountsConnect.RecommendedRenders its children only for the recommended method.

Confirm

Renders once a connection awaits confirmation.

PartDescription
AccountsConnect.ConfirmState wrapper. Read useAccountsConnect().pending for the institution + accounts, build the business/personal form, then call linkInstitutions(accounts).

Manual

Renders the inline “add a manual account” form (selecting the built-in `manual` method, or calling openManual(), opens it).

PartDescription
AccountsConnect.ManualState wrapper. Compose the create-account form inside. Read createManual({ name, mask, type, contributionLedgerId?, distributionLedgerId? }), cancelManual, manualPending, manualError, ledgers and ledgersLoading from useAccountsConnect(). On success the form closes, the accounts query is invalidated and onCreated fires.

Error

PartDescription
AccountsConnect.ErrorState wrapper. Renders its children on connection error.

Hooks

PartDescription
useAccountsConnect()Returns methods, select(method), pending, linkInstitutions(accounts), cancelPending, loading, error, plus the manual-creation surface: manualOpen, openManual, cancelManual, createManual(input), manualPending, manualError, ledgers, ledgersLoading.
useAccountsConnectMethod()Used inside <Methods>; returns the current ConnectionMethod.