nexus-elements-overview
Nexus Elements Overview
Integrate end-to-end in any TS/React app
- Install project deps:
pnpm add @avail-project/nexus-core wagmi viem lucide-react
- If using wagmi (recommended), also install:
pnpm add @tanstack/react-query
- Ensure shadcn/ui is initialized (
components.jsonexists) if installing from registry.
Configure registry
- Add this mapping in
components.json:
"registries": {
"@nexus-elements/": "https://elements.nexus.availproject.org/r/{name}.json"
}
Set up SDK + wallet foundation first
- Install and wire
nexus-providerbefore any other element:npx shadcn@latest add @nexus-elements/nexus-provider
- Wrap your app with
NexusProvider. - On wallet connect, resolve an EIP-1193 provider and call
handleInit(provider). - Pass
config={{ network: "mainnet" | "testnet", debug?: boolean }}toNexusProviderwhen needed.
Minimal provider wrapper
"use client";
import NexusProvider from "@/components/nexus/NexusProvider";
export function AppNexusProvider({ children }: { children: React.ReactNode }) {
return <NexusProvider config={{ network: "mainnet" }}>{children}</NexusProvider>;
}
Initialize SDK on connect
"use client";
import { useEffect } from "react";
import { useAccount, useConnectorClient } from "wagmi";
import type { EthereumProvider } from "@avail-project/nexus-core";
import { useNexus } from "@/components/nexus/NexusProvider";
export function InitNexusOnConnect() {
const { status, connector } = useAccount();
const { data: walletClient } = useConnectorClient();
const { handleInit } = useNexus();
useEffect(() => {
if (status !== "connected") return;
void (async () => {
const mobileProvider = walletClient
? ({ request: (args: unknown) => walletClient.request(args as never) } as EthereumProvider)
: undefined;
const desktopProvider = await connector?.getProvider();
const provider = mobileProvider ?? (desktopProvider as EthereumProvider | undefined);
if (!provider || typeof provider.request !== "function") return;
await handleInit(provider);
})();
}, [status, connector, walletClient, handleInit]);
return null;
}
Install widgets
- Install all widgets:
npx shadcn@latest add @nexus-elements/all
- Or install individually:
@nexus-elements/fast-bridge@nexus-elements/transfer@nexus-elements/swaps@nexus-elements/deposit@nexus-elements/bridge-deposit@nexus-elements/unified-balance@nexus-elements/view-history
SDK function map by widget
FastBridge:sdk.bridgesdk.calculateMaxForBridge- hooks:
setOnIntentHook,setOnAllowanceHook - events:
NEXUS_EVENTS.STEPS_LIST,NEXUS_EVENTS.STEP_COMPLETE
FastTransfer:sdk.bridgeAndTransfersdk.calculateMaxForBridge- hooks:
setOnIntentHook,setOnAllowanceHook - events:
NEXUS_EVENTS.STEPS_LIST,NEXUS_EVENTS.STEP_COMPLETE
SwapWidget:sdk.swapWithExactIn,sdk.swapWithExactOut- hook:
setOnSwapIntentHook - event:
NEXUS_EVENTS.SWAP_STEP_COMPLETE
Deposit:sdk.swapAndExecute- hook:
setOnSwapIntentHook - event:
NEXUS_EVENTS.SWAP_STEP_COMPLETE
BridgeDeposit:sdk.simulateBridgeAndExecutesdk.bridgeAndExecute- hooks:
setOnIntentHook,setOnAllowanceHook - events:
NEXUS_EVENTS.STEPS_LIST,NEXUS_EVENTS.STEP_COMPLETE
UnifiedBalance:sdk.getBalancesForBridge,sdk.getBalancesForSwap
ViewHistory:sdk.getMyIntents
Pick the right widget
- Use
fast-bridgefor self-bridge UX (recipient defaults to connected address). - Use
transferfor bridge-to-recipient UX. - Use
swapsfor exact-in and exact-out cross-chain swaps. - Use
depositfor swap + execute integrations where destination token/chain is fixed by product config. - Use
bridge-depositfor bridge + execute integrations with lighter UI and manual execute builder. - Use
unified-balanceto show cross-chain balances. - Use
view-historyfor intent history.
E2E readiness checklist
- Confirm wallet connects and
handleInitruns once per session. - Confirm
useNexus().nexusSDKis non-null after connect. - Confirm balances load (
bridgableBalance,swapBalance). - Confirm intent hooks are populated during preview states.
- Confirm every flow can reach success and emits explorer URLs.
- Confirm disconnect clears SDK state (
deinitializeNexus).
Common integration failures
- Invalid provider object:
- Ensure provider has
request().
- Ensure provider has
- Widget stuck in preview:
- Ensure hook handlers eventually call
allow()ordeny().
- Ensure hook handlers eventually call
- Empty balances/history:
- Ensure SDK init finished and wallet is connected on a supported network.
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-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-fast-bridge
Integrate the FastBridge element for intent-based cross-chain bridge UX in React/TypeScript apps. Use when installing or debugging self-bridge flows, source-chain selection, allowance gating, step progress events, and `sdk.bridge` execution end-to-end.
21nexus-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