Nexus Widget - Swaps & Bridges
Use NexusWidget with config.mode = "swap" for the unified swap and bridge flow.
For bridge mode configuration, use the Avail Configurator to generate the exact config object based on your token and chain selection.
Installation
npm (recommended):
npm install @avail-project/widgets viem wagmi @tanstack/react-queryshadcn (source files):
npx shadcn@latest add availproject/widgets/nexusConfig Shape
Swap config is intentionally small:
destination.chainis optional. If supplied, receive-chain selection is restricted.destination.tokensis optional. If supplied withdestination.chain, receive-token selection is restricted.prefill.tokenis optional and sets the initial receive token without restricting later choices.recipientAddressis optional for custom-recipient swaps.appearanceis optional.
Swap supports prefill.token only. It does not support prefill.amount, source-token prefill, or validation yet. If destination.tokens is supplied, the first destination token wins and prefill.token is ignored.
npm:
import { NexusWidget } from "@avail-project/widgets";
const USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" as const;
export function SwapWidget({ address }: { address?: `0x${string}` }) {
return (
<NexusWidget
connectedAddress={address}
config={{
mode: "swap",
destination: {
chain: 8453,
tokens: [
{
address: USDC_BASE,
symbol: "USDC",
decimals: 6,
},
],
},
appearance: {
heading: "Swap and Bridge",
mode: "system",
primaryColor: "#0A6BEB",
},
}}
/>
);
}shadcn: Same config, change import to import { NexusWidget } from "@/components/nexus/nexus".
Notes
- Do not use the old
prefill.source,prefill.destination,allowedSourcePairs, orallowedDestinationPairsfields. prefill.tokenmust be shaped as{ chain, address, symbol, decimals, logo? }.- Use the component prop
onConnectClickto open the host app wallet modal.