Install and configure Nexus Elements in your React project. Prebuilt components with full Nexus SDK integration, perfect for plug-and-play.
If you haven't already, set up shadcn/ui in your project first. Follow the official installation guide
Install shadcn/uiOnce installed, come back to continue with Nexus Elements.
You can now start adding Nexus Elements components to your project. The
command below installs the unified-balance component. Replace it
with any other component name as needed.
pnpm dlx shadcn@latest add @nexus-elements/unified-balance
The command will add all required files and dependencies for the selected component.
"use client";
import NexusProvider from "@/components/nexus/NexusProvider";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return <NexusProvider>{children}</NexusProvider>;
}"use client";
import { useEffect } from "react";
import { useAccount } from "wagmi";
import type { EthereumProvider } from "@avail-project/nexus-core";
import { useNexus } from "@/components/nexus/NexusProvider";
export function InitNexusOnConnect() {
const { status, connector } = useAccount();
const { handleInit } = useNexus();
useEffect(() => {
if (status === "connected") {
connector?.getProvider().then((p) => handleInit(p as EthereumProvider));
}
}, [status, connector, handleInit]);
return null;
}On This Page
Important Note