Appearance
useCoinbaseAvailability / CoinbaseGuard
Check whether Coinbase OAuth (provider: coinbase, type: exchange_oauth) is available for the current session before showing connect / withdraw UI.
Requires SwappedConnectProvider. Does not require CoinbaseProvider.
When to use
Gate the Coinbase flow after payment methods load. Prefer CoinbaseGuard for simple loading / unavailable UI (and optional navigate). Use useCoinbaseAvailability when you need the payment method object or custom branching.
CoinbaseGuard
tsx
import { CoinbaseGuard } from '@swapped/connect-sdk/react'
import { useNavigate } from 'react-router-dom'
function CoinbaseRoute() {
const navigate = useNavigate()
return (
<CoinbaseGuard
loading={<p>Loading…</p>}
fallback={<p>Coinbase is not available for this session</p>}
onNotAvailable={() => navigate('/payment-methods')}
>
<ConnectCoinbase />
</CoinbaseGuard>
)
}| Prop | Default | Purpose |
|---|---|---|
children | — | Rendered when Coinbase is available |
loading | null | Shown while payment methods load |
fallback | null | Shown when Coinbase is not available |
onNotAvailable | — | Called once when loading finishes and Coinbase is unavailable (navigate / redirect). Independent of fallback |
useCoinbaseAvailability
tsx
import { useCoinbaseAvailability } from '@swapped/connect-sdk/react'
function CoinbaseEntry() {
const { isAvailable, isLoading, paymentMethod, error } =
useCoinbaseAvailability()
if (isLoading) return <p>Loading…</p>
if (error) return <p>{error.message}</p>
if (!isAvailable) return <p>Coinbase is not available for this session</p>
return <p>Continue with {paymentMethod?.name}</p>
}| Field | Purpose |
|---|---|
isAvailable | true when Coinbase OAuth is present (false while loading) |
paymentMethod | Matching payment method, if any |
isLoading / isRefetching | Fetch state |
error | Last load failure |
refetch | Force reload payment methods |