Skip to main content
Socket Widget is a swap and bridge widget for moving tokens across blockchains. The @socket.tech/widget package exposes a React component you can embed in your app.
v1.0.0: The widget is wallet-provider-agnostic. Your app provides a minimal wallet adapter via config.wallet, and the widget handles routing, reads, writes, balances, receipts, and signing internally.

Before You Start

Socket Widget handles swap and bridge flows, while your app owns wallet connection.
  • Provide wallet state and wallet connect UI.
  • Mount QueryClientProvider above <SocketWidget />.
  • Pass a minimal wallet adapter via config.wallet.
  • Support EVM only, Solana only, Tron only, or any combination by providing the matching adapter methods. You only need to pass the methods for the chains you support — e.g. for EVM-only apps, provide getEVMWalletClient and switchChain; you do not need to pass getSolanaSigner or getTronWeb.
Minimal React Query setup:

Install

Peer dependencies are not installed automatically. You must already have wallet infrastructure in your app.
Import the widget styles in your app entrypoint:

Quickstart

  1. Install the package and peer dependencies.
  2. Mount QueryClientProvider.
  3. Import the widget CSS.
  4. Add a minimal wallet adapter.
  5. Render <SocketWidget config={config} />.
Choose the smallest path that matches your app:
  • EVM only: provide accounts, getEVMWalletClient, and usually switchChain.
  • Solana only: provide accounts, getSolanaSigner, and rpcs.solana.
  • Tron: provide accounts and getTronWeb.
  • EVM + Solana: combine both adapters in the same wallet object.
  • EVM + Tron: add getTronWeb and TRON accounts for Tron-supported routes.

EVM-Only Example

Solana-Only Example

To support both EVM and Solana, combine this signer with the EVM adapter shown above in the same wallet object.

Adding Tron (optional)

  • Include TRON accounts in wallet.accounts (with chainType: "TRON")
  • Provide getTronWeb returning your app’s TronWeb instance (must satisfy TronWebLike)
  • Route eventHandlers.onOpenWalletConnect("tron") to open your Tron wallet UI
If you do not pass getTronWeb, the widget works normally; Tron routes won’t be available.

Configuration Reference

WidgetConfig

Required

Optional

Feature Flags

  • internalToasts (boolean): Show or hide internal toasts (default: true)
  • internalTxHistory (boolean): Show or hide transaction history (default: true)
  • internalInflight (boolean): Show or hide the inflight screen as a non-blocking toast (default: true)
  • internalTokenSelector (boolean): Render the built-in token selector, or delegate token selection to your app via eventHandlers.onOpenTokenSelector (default: true)
  • internalTokenSelectorBounds ("widget" | "viewport"): Constrain the built-in token selector to the widget or viewport (default: "widget")

Base URL and Auth Requirements

The widget uses a single default backend root: https://backend.socket.tech/v3.
  • If you do not pass baseUrl, the widget uses the Socket backend URL above.
  • affiliateId is required in every config.
  • turnstileSiteKey is optional. Pass it only if you want JWT-authenticated requests.
  • You may still override baseUrl explicitly if you need to point the widget at a different compatible backend.

Wallet Adapter

The wallet object is the only host integration point the widget needs. You provide connected accounts and the network-specific wallet hooks you support; the widget handles the rest internally.

What the widget handles internally

When you provide getEVMWalletClient, the widget automatically implements:
  • sendTransaction (including EIP-5792 batched calls)
  • signTypedData
  • writeContract
  • readContract (via viem public clients)
  • getBalance (native + ERC-20)
  • getTransactionReceipt
  • getBytecode
  • getEnsAddress
  • getWalletCapabilities (EIP-5792)
  • getCallsStatus (EIP-5792)
When you provide getSolanaSigner and config.rpcs.solana, the widget additionally handles:
  • Solana transaction building and sending (VersionedTransaction with lookup tables)
  • SOL and SPL token balance fetching (including Token-2022)
  • Solana transaction receipt polling
When you provide getTronWeb, the widget additionally handles:
  • Tron transaction building, signing, and broadcasting (for deposit and direct-deposit flows)
  • TRX and TRC-20 balance and transaction receipt via the host-supplied TronWeb instance

accounts

An array of currently connected wallet accounts:

getEVMWalletClient

Returns a viem WalletClient for the requested chain. The widget uses this to send transactions, sign typed data, write contracts, and query EIP-5792 capabilities.
The return type is any in the adapter interface so hosts are free to use any viem version; the widget casts internally.

getSolanaSigner

Returns a Solana signer object. The widget builds the transaction internally (instructions, lookup tables, blockhash) and passes it to the signer. If the signer provides signAndSendTransaction, the widget prefers it; otherwise it falls back to signTransaction + sendRawTransaction via its internal Connection.

getTronWeb

Returns the wallet-connected TronWeb instance from your app. The widget uses it to build, sign, and broadcast Tron transactions for deposit and direct-deposit flows. The instance must implement the minimal TronWebLike interface (see type export). If you do not support Tron, omit this property.

switchChain

Switches the wallet’s active EVM chain. The optional account parameter targets a specific wallet when multiple are connected. Treat this as a success-or-throw contract in practice:
  • resolve when the chain switch succeeds
  • reject or throw if the switch is cancelled or fails

Token Configuration Details

Token Interface

Using supportedTokens

Important notes:
  • When supportedTokens are provided, the widget will not automatically set a default token.
  • To show a default source token, you must pass initialValues.fromChain and initialValues.inputTokens.
  • Set isVerified: true for tokens in supportedTokens to avoid warnings.
  • inputTokens addresses must match tokens from your supportedTokens.from[chainId] list.

Fetching Token Data

When using supportedTokens, you can fetch token data from the Socket API endpoints:
  • /tokens/list: Returns a curated list of trending tokens (verified) or the complete token list
  • /tokens/search: Search for tokens by address, name, or symbol
Tokens fetched from these endpoints include the isVerified field. For detailed request and response formats, see the token-list API documentation.

Theme Configuration

Customize the widget appearance with the theme property:
Colors support both hex (#FFFFFF) and RGB (rgb(255, 255, 255)) formats.

Event Handlers

Handle user interactions and widget events:

Imperative API

The imperative API allows parent components to control widget state programmatically. Use case example: when a user clicks a history item in a sidebar, the parent can navigate the widget to the inflight screen for that transaction.
Available methods:
  • setInflightData(data: OrderData): Track pending transactions and navigate to inflight screen
  • openQrDeposit(quoteId: string): Open the QR deposit screen for a quote
  • selectToken(token: Token, isSource: boolean): Programmatically select the source or destination token
  • setSourceWalletMode(mode: SourceWalletMode): Update the source wallet mode used by the widget

Type Exports


Troubleshooting