Get Started
We built a React demo app that uses the Avail Nexus SDK UI components to implement a unified Web3 experience.
- You can use the app here:
nexus-ui-components-demo.vercel.app
- You can find the code for the app here:
availproject/nexus-ui-components-demo
The Avail Nexus SDK provides both headless functionality and pre-built React UI components. This guide covers the React UI components which offer the fastest way to integrate chain abstraction into your React app.
The SDK provides BridgeButton
, TransferButton
, and BridgeAndExecuteButton
components. Each widget is covered in detail in the following pages.
The Avail Nexus SDK provides some built-in React widgets that make it easier for devs to integrate the SDK into their existing React app.
Get NexusProvider
Wrap your app with the NexusProvider
.
Enable the Nexus SDK functionality by adding the NexusProvider
to your app’s root component. (For e.g.,layout.tsx
in Next.js or App.tsx
in Remix, etc.):
import { NexusProvider } from '@avail-project/nexus/ui';
export default function Root() {
return (
<NexusProvider
config={{
network: 'testnet', // "mainnet" (default) or "testnet"
}}
>
<App />
</NexusProvider>
);
}
FOR EXAMPLE:
The demo app sets up the NexusProvider
in the __root.tsx file,
wrapping the entire application with both wallet authentication (Privy) and the Nexus provider.
Use UI Components
Use UI Components
Forward the user’s wallet provider and drop a widget into your UI. The UI components handle the SDK initialization for you.
The following example shows how you would use the bridge button, but other widgets are covered in the following pages:
// Complete example showing both wallet provider setup AND widget usage
import { useEffect } from 'react';
import { useAccount } from '@wagmi/react';
import { useNexus, BridgeButton } from '@avail-project/nexus/ui';
function MyApp() {
const { connector, isConnected } = useAccount();
const { setProvider } = useNexus();
// Forward wallet provider
useEffect(() => {
if (isConnected && connector?.getProvider) {
connector.getProvider().then(setProvider);
}
}, [isConnected, connector, setProvider]);
// Use UI widgets (initialization happens automatically)
return (
<BridgeButton prefill={{ chainId: 137, token: 'USDC', amount: '100' }}>
{({ onClick, isLoading }) => (
<button onClick={onClick} disabled={isLoading}>
{isLoading ? 'Bridging…' : 'Bridge 100 USDC → Polygon'}
</button>
)}
</BridgeButton>
);
}
Any wallet library works: The example shows Wagmi, but you can use Privy, RainbowKit, ConnectKit, or any library that provides an EIP-1193 provider.
The demo app uses Privy and forwards the provider in connect-wallet.tsx .
What do we mean by “unified balance”?
Unified balance shows all the liquidity in a user’s EOA account across multiple chains in one view. It lets users transact seamlessly on any chain without needing bridges or pre-provisioning gas for token swaps. Chain abstraction handles all the complexity involved in a cross-chain transaction while enabling better UX through a single intent approval.
For instance, let us take the case where a user intends to spend 18 USDC on Scroll and does not have any balance on Scroll.
- Optimism: 0.1 ETH, O USDT, 0 USDC
- Arbitrum: 0 ETH, 12 USDT, 0 USDC
- Base: 0 ETH, 10 USDT, 0 USDC
- Scroll: 0 ETH, 0 USDT, 0 USDC
To spend 18 USDC on Scroll (destination chain) with the given liquidity fragmentation, it would typically require multiple clicks and steps for swapping or bridging different assets available on the source chains, so that user can convert the assets to the desired token balance on Scroll.
Through chain abstraction and ability to swap cross-chain, users have the convenience to view the consolidated token balance across supported tokens and chains. This simplifies the process of sending 18 USDC on Optimism, as users can sign the intent without the need for bridging, swapping, or considering the optimal routes.
The cross-chain swap enables users to:
- Spend assets on any destination chain without prior liquidity.
- Collate payable amount by combining multiple supported assets across source chains to address liquidity fragmentation.