Skip to content

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>
  )
}
PropDefaultPurpose
childrenRendered when Coinbase is available
loadingnullShown while payment methods load
fallbacknullShown when Coinbase is not available
onNotAvailableCalled 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>
}
FieldPurpose
isAvailabletrue when Coinbase OAuth is present (false while loading)
paymentMethodMatching payment method, if any
isLoading / isRefetchingFetch state
errorLast load failure
refetchForce reload payment methods