@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 thebusiness/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:createplaid:readledger:readtransaction:create
API reference
Root props
| Prop | Type | Default | Description |
|---|---|---|---|
onConnected | (institutions, account) => void | — | Called after the accounts are linked on the Asset API. |
onCreated | () => void | — | Called after a manual account is successfully created. |
onError | (error) => void | — | Called if creating the link token or linking fails. |
onSelectMethod | (method) => void | — | Called when a method other than the built-in plaid / manual flows (gusto / quickbooks) is selected. |
methods | ConnectionMethod[] | — | 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 / onEvent | PlaidLink callbacks | — | Forwarded to Plaid Link. |
initialPending | PlaidInstitutionAccount | null | — | Seed the confirm state (testing/storybook). |
state | "loading" | "error" | — | Force a specific state for testing. |
childrenrequired | ReactNode | — | Compound parts. |
Parts
Default
Renders while choosing a connection method.
| Part | Description |
|---|---|
AccountsConnect.Default | State wrapper. Compose the method list inside. |
AccountsConnect.Methods | Iterates each connection method, providing a method context. |
AccountsConnect.MethodTriggerasChild? | Button that selects the current method — Plaid opens Plaid Link, others fire onSelectMethod. Sets data-method and disables the Plaid card while loading. |
AccountsConnect.MethodTitleasChild? | Renders the method's title. |
AccountsConnect.MethodDescriptionasChild? | Renders the method's description. |
AccountsConnect.Recommended | Renders its children only for the recommended method. |
Confirm
Renders once a connection awaits confirmation.
| Part | Description |
|---|---|
AccountsConnect.Confirm | State 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).
| Part | Description |
|---|---|
AccountsConnect.Manual | State 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
| Part | Description |
|---|---|
AccountsConnect.Error | State wrapper. Renders its children on connection error. |
Hooks
| Part | Description |
|---|---|
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. |