Appearance
Cash App (React)
Deposit with Cash App using hooks from @swapped/connect-sdk/react. Route here when the payment method has type: cash_app (see Payment methods).
The user picks a destination asset and a fiat amount (currently USD), then pays in Cash App or with a Lightning invoice.
Prerequisites
- Create a core client with a Swapped Connect
sessionId(from your backend). - Call
loadSession()and wrap your tree withSwappedConnectProvider. - Wrap the deposit UI with CashAppProvider.
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>
)
}Flow overview
| Step | What happens | Hook |
|---|---|---|
| 1. Assets | Load destination tokens | useCashAppSupportedAssets, useCashAppAsset |
| 2. Amount | Validate fiat amount (currently USD) | useCashAppAmount |
| 3. Create order | createOrder() from selection | useCashAppOrder, useCashAppSelection |
| 4. Checkout | Show Cash App URL / Lightning invoice | useCashAppOrder |
| 5. Wait | Completion, failure, or countdown | Expiry & countdown, Event hooks |
| 6. Done | Summary; restartSession() | useCashAppCompletedTransactionSummary |
Session must be loaded and active before createOrder. After a completed payment, call restartSession() before starting again.
Step-by-step walkthrough: Example.
Hooks
Full list: Cash App hooks. Use state hooks for UI and event hooks for side effects (navigate, toast).