nexus-elements-fast-bridge
Nexus Elements - Fast Bridge
Install
- Install widget:
npx shadcn@latest add @nexus-elements/fast-bridge
- Ensure
NexusProvideris installed and initialized on wallet connect before renderingFastBridge.
Required setup before rendering
- Ensure
useNexus().nexusSDKis non-null. - Ensure
bridgableBalancehas loaded. - Pass connected wallet address as
connectedAddress.
Initialize SDK (required once per app)
- On wallet connect, resolve an EIP-1193 provider and call
useNexus().handleInit(provider). - Wait for
useNexus().nexusSDKbefore allowing bridge actions. - Re-run init after reconnect if wallet session resets.
Render widget
"use client";
import FastBridge from "@/components/fast-bridge/fast-bridge";
import { SUPPORTED_CHAINS } from "@avail-project/nexus-core";
export function BridgePanel({ address }: { address: `0x${string}` }) {
return (
<FastBridge
connectedAddress={address}
prefill={{
token: "USDC",
chainId: SUPPORTED_CHAINS.BASE,
}}
onStart={() => {
// track pending state
}}
onComplete={() => {
// show success state
}}
onError={(message) => {
console.error(message);
}}
/>
);
}
Live prop contract
connectedAddress(required): connected wallet address.prefill?:token,chainId, optionalamount, optionalrecipient.
maxAmount?: cap bridgeable amount.onStart?,onComplete?,onError?(message)callbacks.
SDK flow details (under the hood)
- Primary execute call:
sdk.bridge({ token, amount, toChainId, recipient, sourceChains }, { onEvent })
- Pre-execution validation and limits:
- input validation (token/chain/recipient/amount)
sdk.calculateMaxForBridge(...)for selected sources- source coverage checks before allow/execute
- Hook usage:
intent.currentstoresOnIntentHookDataallowance.currentstoresOnAllowanceHookData- flow calls
intent.refresh(selectedSources)before accept
- Event mapping:
NEXUS_EVENTS.STEPS_LISTseeds progress stepsNEXUS_EVENTS.STEP_COMPLETEupdates step completion and timer start
Understand source selection behavior
- Widget computes available sources from token breakdown excluding destination chain.
- Widget tracks selected source chains and coverage against required amount.
- Widget blocks accept/execute when source coverage is insufficient.
E2E verification
- Enter valid amount/recipient and confirm preview appears (intent hook received).
- Toggle sources and confirm max amount and coverage update.
- Accept flow and confirm allowance modal appears only when needed.
- Confirm transaction progresses through steps and returns explorer URL.
- Confirm balances refresh after success.
Common failure cases
Nexus SDK not initialized:- confirm
handleInit(provider)ran.
- confirm
- Source coverage errors:
- increase amount coverage or add more source chains.
- Stuck preview:
- ensure
allow()ordeny()is called from hook-driven UI.
- ensure
More from availproject/nexus-elements
nexus-elements-deposit
Integrate the Deposit element for swap-plus-execute deposit flows in React/TypeScript apps. Use when installing or debugging destination-fixed deposits, execute call builders, swap-intent confirmation UX, and `sdk.swapAndExecute` progress from quote to completion.
26nexus-elements-overview
End-to-end integration guide for Nexus Elements in any TypeScript/React codebase. Use when setting up Nexus Elements from scratch, choosing which widget to install, wiring NexusProvider + wallet initialization, or validating bridge/transfer/swap/deposit/history behavior in production-like flows.
24nexus-elements-common
Use shared Nexus Elements hooks, transaction-step helpers, and constants to build custom Nexus UX. Use when extending widgets or implementing custom bridge/transfer/swap/deposit flows that need debouncing, polling, step orchestration, or Nexus error normalization.
23nexus-elements-nexus-provider
Install and configure NexusProvider for Nexus Elements with full SDK lifecycle wiring. Use when setting up or debugging SDK initialization, wallet/provider connection, hook attachment (intent/allowance/swapIntent), balance preloads, exchange-rate support, and provider context consumption in React/TypeScript apps.
23nexus-elements-bridge-deposit
Integrate the Bridge Deposit element for bridge-plus-execute deposit flows in React/TypeScript apps. Use when installing or debugging source-chain constrained deposits, bridge+execute simulation, intent/allowance approvals, and `sdk.bridgeAndExecute` transaction execution.
22nexus-elements-unified-balance
Integrate the UnifiedBalance element for cross-chain token balance views in React/TypeScript apps. Use when installing or debugging bridgeable/swappable balance aggregation, per-chain breakdown rendering, and formatting powered by Nexus SDK balance APIs.
21