Skip to content

Getting started (Core)

Use the framework-agnostic client from @swapped/connect-sdk.

Install

bash
npm install @swapped/connect-sdk

Create client and load session

ts
import { createSwappedConnectClient } from '@swapped/connect-sdk';

const client = createSwappedConnectClient({
  sessionId: 'your-session-id',
  // apiBaseUrl: 'https://connect-api.swapped.com', // optional
});

await client.loadSession();

const session = client.getSession();
console.log(session?.merchant.name);

You need a Swapped Connect sessionId from your backend before creating the client.

Typical order of work

  1. createSwappedConnectClientloadSession
  2. Gate UI on session view (getSessionView) — only active can pay
  3. List payment methods
  4. Run a deposit flow — Wallets, Exchange Pay, or Coinbase
  5. Listen for events as needed
  6. restartSession() for another payment, or destroy() when done

Entry points

ImportPurpose
@swapped/connect-sdkClient, types, modules
@swapped/connect-sdk/formatDisplay helpers

Prefer React? See the React track.