Skip to content

@swapped/connect-sdk / core / SwappedConnectClient

Type Alias: SwappedConnectClient ​

SwappedConnectClient = object

Defined in: src/client.ts:102

Framework-agnostic Swapped Connect client.

Created by createSwappedConnectClient. Owns session lifecycle, payment methods, Exchange Pay, and event subscriptions.

Browser only - do not construct or use this client on the server (Node.js, SSR, RSC).

Properties ​

cashApp ​

cashApp: CashApp

Defined in: src/client.ts:154

Cash App onramp module. Always available unless modules was passed without cashApp (MODULE_NOT_ENABLED). Create-order actions require a loaded session.


coinbase ​

coinbase: Coinbase

Defined in: src/client.ts:160

Coinbase exchange OAuth module. Always available unless modules was passed without coinbase (MODULE_NOT_ENABLED). Connect/withdraw actions require a loaded session.


destroy ​

destroy: () => void

Defined in: src/client.ts:178

Tear down the client and release internal resources.

Returns ​

void


exchangePay ​

exchangePay: ExchangePay

Defined in: src/client.ts:148

Exchange Pay module. Always available unless modules was passed without exchangePay (MODULE_NOT_ENABLED). Order/create actions require a loaded session.


getMaintenanceStatus ​

getMaintenanceStatus: () => MaintenanceStatusPayload | null

Defined in: src/client.ts:130

Return the current maintenance status, or null if none has been received.

Returns ​

MaintenanceStatusPayload | null


getSession ​

getSession: () => SessionData | null

Defined in: src/client.ts:124

Return the last loaded session payload, or null if none.

Returns ​

SessionData | null


getSessionId ​

getSessionId: () => string

Defined in: src/client.ts:128

Return the active session id.

Returns ​

string


getSessionView ​

getSessionView: () => SessionView

Defined in: src/client.ts:126

Return the classified session view for the current session state.

Returns ​

SessionView


getState ​

getState: () => SwappedConnectState

Defined in: src/client.ts:132

Return a snapshot of public client state.

Returns ​

SwappedConnectState


isModuleEnabled ​

isModuleEnabled: (module) => boolean

Defined in: src/client.ts:142

Whether this client constructed the given payment module.

Parameters ​

module ​

SwappedConnectModule

Returns ​

boolean


loadSession ​

loadSession: {(sessionId?, options?): Promise<SessionData>; (options): Promise<SessionData>; }

Defined in: src/client.ts:114

Load (or reload) the session for the given or configured sessionId. Rejects with ConnectSdkErrorCode.SESSION_RESTART_IN_PROGRESS if a restart is already running, or ConnectSdkErrorCode.SESSION_ALREADY_IN_USE if another live client already has that sessionId.

A second call with the same id uses the cached payload unless LoadSessionOptions.forceRefetch is true. You usually do not need forceRefetch - sockets and payment completion already refresh the session.

Call Signature ​

(sessionId?, options?): Promise<SessionData>

Parameters ​
sessionId? ​

string

options? ​

LoadSessionOptions

Returns ​

Promise<SessionData>

Call Signature ​

(options): Promise<SessionData>

Parameters ​
options ​

LoadSessionOptions

Returns ​

Promise<SessionData>


modules ​

modules: readonly SwappedConnectModule[]

Defined in: src/client.ts:140

Enabled payment modules. Omit modules on create to get every module.


off ​

off: <E>(event, handler) => void

Defined in: src/client.ts:173

Remove a previously registered event handler.

Type Parameters ​

E ​

E extends keyof SwappedConnectEventMap

Parameters ​

event ​

E

handler ​

(payload) => void

Returns ​

void


on ​

on: <E>(event, handler) => () => void

Defined in: src/client.ts:168

Subscribe to a lifecycle event; returns an unsubscribe function.

Type Parameters ​

E ​

E extends keyof SwappedConnectEventMap

Parameters ​

event ​

E

handler ​

(payload) => void

Returns ​

() => void


paymentMethods ​

paymentMethods: PaymentMethods

Defined in: src/client.ts:136

Payment methods module for the current session.


restartSession ​

restartSession: (sessionId?) => Promise<SessionData>

Defined in: src/client.ts:122

Start a new transaction for the same merchant flow; clears Exchange Pay state. Rejects if a load or restart is already running.

Parameters ​

sessionId? ​

string

Returns ​

Promise<SessionData>


subscribe ​

subscribe: (listener) => () => void

Defined in: src/client.ts:134

Subscribe to public state changes; returns an unsubscribe function.

Parameters ​

listener ​

(state) => void

Returns ​

() => void


wallets ​

wallets: Wallets

Defined in: src/client.ts:166

Browser wallets module. Always available unless modules was passed without wallets (MODULE_NOT_ENABLED). Connect and balances require a loaded session (and the gateway host iframe).