@socket.tech/widget package exposes a React component you can embed in your app.
- Live product: bungee.exchange
- NPM package: @socket.tech/widget
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
QueryClientProviderabove<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
getEVMWalletClientandswitchChain; you do not need to passgetSolanaSignerorgetTronWeb.
Install
Peer dependencies are not installed automatically. You must already have wallet infrastructure in your app.
Quickstart
- Install the package and peer dependencies.
- Mount
QueryClientProvider. - Import the widget CSS.
- Add a minimal wallet adapter.
- Render
<SocketWidget config={config} />.
- EVM only: provide
accounts,getEVMWalletClient, and usuallyswitchChain. - Solana only: provide
accounts,getSolanaSigner, andrpcs.solana. - Tron: provide
accountsandgetTronWeb. - EVM + Solana: combine both adapters in the same
walletobject. - EVM + Tron: add
getTronWeband TRON accounts for Tron-supported routes.
EVM-Only Example
Solana-Only Example
wallet object.
Adding Tron (optional)
- Include TRON accounts in
wallet.accounts(withchainType: "TRON") - Provide
getTronWebreturning your app’s TronWeb instance (must satisfyTronWebLike) - Route
eventHandlers.onOpenWalletConnect("tron")to open your Tron wallet UI
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 viaeventHandlers.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. affiliateIdis required in every config.turnstileSiteKeyis optional. Pass it only if you want JWT-authenticated requests.- You may still override
baseUrlexplicitly if you need to point the widget at a different compatible backend.
Wallet Adapter
Thewallet 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 providegetEVMWalletClient, the widget automatically implements:
sendTransaction(including EIP-5792 batched calls)signTypedDatawriteContractreadContract(via viem public clients)getBalance(native + ERC-20)getTransactionReceiptgetBytecodegetEnsAddressgetWalletCapabilities(EIP-5792)getCallsStatus(EIP-5792)
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
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.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 providessignAndSendTransaction, 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 minimalTronWebLike interface (see type export). If you do not support Tron, omit this property.
switchChain
Switches the wallet’s active EVM chain. The optionalaccount 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
supportedTokensare provided, the widget will not automatically set a default token. - To show a default source token, you must pass
initialValues.fromChainandinitialValues.inputTokens. - Set
isVerified: truefor tokens insupportedTokensto avoid warnings. inputTokensaddresses must match tokens from yoursupportedTokens.from[chainId]list.
Fetching Token Data
When usingsupportedTokens, 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
isVerified field. For detailed request and response formats, see the token-list API documentation.
Theme Configuration
Customize the widget appearance with thetheme property:
#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.setInflightData(data: OrderData): Track pending transactions and navigate to inflight screenopenQrDeposit(quoteId: string): Open the QR deposit screen for a quoteselectToken(token: Token, isSource: boolean): Programmatically select the source or destination tokensetSourceWalletMode(mode: SourceWalletMode): Update the source wallet mode used by the widget