Appearance
CashAppProvider
Owns Cash App deposit selection (asset, amount), the active order, and shared fetched data for the React hooks.
When to use
Wrap the Cash App deposit UI under SwappedConnectProvider. Selection hooks (useCashAppSupportedAssets, useCashAppAsset, useCashAppAmount, …) and useCashAppOrder require this provider.
Checkout / summary screens that call useCashAppOrder also need the provider (even when they do not show the form). Order state is shared across the tree, so the form and checkout see the same order.
Example
tsx
import { createSwappedConnectClient } from '@swapped/connect-sdk'
import {
CashAppProvider,
SwappedConnectProvider,
} from '@swapped/connect-sdk/react'
const client = createSwappedConnectClient({
sessionId: 'your-session-id',
})
void client.loadSession()
function App() {
return (
<SwappedConnectProvider client={client}>
<CashAppProvider>
<DepositScreen />
</CashAppProvider>
</SwappedConnectProvider>
)
}Props
| Prop | Default | Purpose |
|---|---|---|
autoSelectAsset | true | Auto-select the default or first supported asset |
defaultAsset | — | Preferred { asset, chain } when present in the list |
enabled | true | Skip asset fetch when false |
adjustAmountOnAssetChange | false | When the asset changes and the current amount is above 0 but below the new minimum, bump the amount up to that minimum |
Selection is uncontrolled: pass defaultAsset only as the initial value.
Related hooks
| Hook | Role |
|---|---|
| useCashAppSupportedAssets | Destination asset list |
| useCashAppAsset | Selected asset |
| useCashAppAmount | Amount + minimum |
| useCashAppSelection | Full selection snapshot |
| useCashAppOrder | Shared order + createOrder() / createOrder(request) |
Errors
| Code | When |
|---|---|
REACT_CASH_APP_PROVIDER_REQUIRED | A selection/data hook is used outside CashAppProvider |
See Errors.