Appearance
Getting started (Core)
Use the framework-agnostic client from @swapped/connect-sdk.
This SDK is browser only. Do not create a client or call SDK methods on the server (Node.js, SSR, RSC). createSwappedConnectClient throws BROWSER_REQUIRED if it is initialized outside the browser. Session creation stays on your backend — see Creating a session. If your site sends a Content-Security-Policy, allow the Swapped widget and API origins — see Browser requirements.
Install
bash
npm install @swapped/connect-sdkReact is not required. Install it only if you use the React track.
Create client and load session
ts
import { createSwappedConnectClient } from '@swapped/connect-sdk';
const client = createSwappedConnectClient({
sessionId: 'your-session-id',
environment: 'staging', // omit or 'production' for live
});
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 — see Creating a session. Create that session against the same environment the client uses.
Config (environment, modules, apiBaseUrl, widgetBaseUrl), lifecycle (loadSession, restartSession, destroy), and client errors: Client.
Typical order of work
createSwappedConnectClient→loadSession— Client- Gate UI on session view (
getSessionView) — onlyactivecan pay - List payment methods
- Run a deposit flow — Wallets, Exchange Pay, Cash App, or Coinbase
- Listen for events as needed
restartSession()for another payment, ordestroy()when done
Entry points
| Import | Purpose |
|---|---|
@swapped/connect-sdk | Client, types, modules |
@swapped/connect-sdk/locales | Language |
@swapped/connect-sdk/format | Display helpers |
Prefer React? See the React track.