Documentation Index
Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This guide shows you how to build a custom multi-chain bridging interface from scratch using Dynamic SDK hooks. You’ll learn how to:- Connect a source wallet on one chain (e.g., EVM, Solana, Bitcoin, Sui)
- Connect a destination wallet on another chain
- Select and switch between different chains
- Manage multiple wallet connections simultaneously
- Access wallet instances to perform bridge transactions
Setup
Configure yourDynamicContextProvider with the required wallet connectors for all chains you want to support:
providers.tsx
Core Hooks
Use these Dynamic SDK hooks:useDynamicContext- SDK state and wallet management (sdkHasLoaded,removeWallet,primaryWallet)useUserWallets- Get all connected walletsuseSwitchWallet- Switch the primary walletuseWalletOptions- Get available wallets and connect (selectWalletOption,getFilteredWalletOptions)FilterChain- Filter wallets by chain typeChainEnum- Chain type constants
Chain Constants
First, create a constants file to define chain display names and supported chains:consts.ts
Chain Selector Component
Create a chain selector component to allow users to choose source and destination chains:ChainSelector.tsx
ChainSelector component provides a dropdown interface for selecting chains. It displays chain names from a predefined list and can be configured to filter available options, making it reusable for both source and destination chain selection. To customize which chains appear, update the CHAIN_DISPLAY_NAMES and SUPPORTED_CHAINS constants in src/lib/consts.ts.
Wallet Modal Component
Create a modal component for connecting wallets:WalletModal.tsx
WalletModal component displays available wallets for a specific chain when opened. It filters wallets by chain type using FilterChain, sorts them to show installed wallets first, and handles wallet connection via selectWalletOption. The modal closes automatically after a wallet is selected.
Complete Implementation
Here’s the complete bridge component that matches the real implementation:HeadlessBridgeWidget.tsx
useEffect hook. The component uses memoization (useMemo) for performance optimization and callbacks (useCallback) to prevent unnecessary re-renders.
Key Concepts
Primary Wallet vs Destination Wallet
- Source Wallet: Should be the primary wallet (use
switchWalletto set it). The source wallet is automatically set as primary when connected. - Destination Wallet: Can be any connected wallet (track with
selectedDestinationWalletId). The destination wallet doesn’t need to be primary.
Chain Selection
The component prevents selecting the same chain for both source and destination:useMemo hook recalculates available chains only when the destination chain changes, preventing invalid bridge configurations.
Wallet Filtering
Filter wallets by chain usingFilterChain:
FilterChain is a utility function that creates a filter predicate for wallet options. When passed to getFilteredWalletOptions, it returns only wallets compatible with the specified chain type, making it easy to show chain-specific wallet options in your UI.
Connecting Wallets
UseselectWalletOption to connect a new wallet:
selectWalletOption connects a new wallet to the user’s account. The second parameter (createLinkedAccount: true) creates a linked account if needed, and the third parameter (setAsPrimary: true) makes the newly connected wallet the primary wallet, which is important for the source wallet in bridge transactions.
Accessing Wallet Instances
EVM Wallet
Solana Wallet
Bitcoin Wallet
Sui Wallet
Next Steps: Integrating Bridge Providers
Now that you have a custom multi-chain bridging UI set up, you can integrate with bridge providers to enable actual token transfers between chains. Check out our integration guides:- LiFi Integration - Integrate LiFi for cross-chain swaps and bridges
- Mayan Integration - Use Mayan for cross-chain bridging
- Circle Gateway Integration - Integrate Circle Gateway for USDC transfers across chains
See Also
- Dynamic Bridge Widget - For a complete UI solution
- Enabling Chains - Configure supported chains
- useUserWallets Hook - Access wallet functionality
- useWalletOptions Hook - Connect wallets