Agent skill
nexus-elements-nexus-provider
Install and configure the NexusProvider for Nexus Elements. Use when setting up provider context, handleInit on wallet connect, or when any element needs useNexus.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/nexus-elements-nexus-provider
SKILL.md
Nexus Elements - NexusProvider
Overview
Install NexusProvider, initialize the SDK once on wallet connect, and access Nexus context via useNexus. All Nexus Elements widgets depend on this provider.
What NexusProvider does
- Creates a single
NexusSDKinstance (configurablenetworkanddebug). - Initializes the SDK with an EIP-1193 provider (
handleInit). - Preloads:
- supported chains/tokens (bridge + swap)
- bridgeable and swappable balances
- exchange rates (Coinbase) for fiat display
- Attaches SDK hooks for intent, allowance, and swap intent previews.
- Exposes all of the above to components via
useNexus().
Install (shadcn registry)
- Ensure shadcn/ui is initialized (
components.jsonexists). - Ensure registry mapping exists:
"registries": {
"@nexus-elements/": "https://elements.nexus.availproject.org/r/{name}.json"
}
- Install:
npx shadcn@latest add @nexus-elements/nexus-provider
Alternative:
npx shadcn@latest add https://elements.nexus.availproject.org/r/nexus-provider.json
Manual install (no shadcn)
- Download
https://elements.nexus.availproject.org/r/nexus-provider.json. - Create each file in
files[].targetwithfiles[].content. - Install dependencies:
@avail-project/nexus-core@1.0.0-beta.64andwagmi.
Usage
Wrap your app:
"use client";
import NexusProvider from "@/components/nexus/NexusProvider";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return <NexusProvider>{children}</NexusProvider>;
}
Initialize on wallet connect (wagmi example):
"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;
}
What useNexus() provides
nexusSDK: initialized SDK instance (ornullbefore init)handleInit(provider): init + preload + attach hooksinitializeNexus(provider)/deinitializeNexus(): manual lifecycle controlintent,allowance,swapIntent: refs for SDK hooks (must callallow()/deny())supportedChainsAndTokens,swapSupportedChainsAndTokensbridgableBalance,swapBalanceexchangeRate,getFiatValue(amount, symbol)fetchBridgableBalance(),fetchSwapBalance()loading,network
Notes
handleInitexpects an EIP-1193 provider withrequest().- Optional
configsupportsnetwork("mainnet"/"testnet"or custom) anddebug. - Hooks are attached in
handleInit; if you override hooks elsewhere, always callallow()/deny()or flows will stall. - Provider auto-deinitializes on wallet disconnect via wagmi
useAccountEffect; if not using wagmi, calldeinitializeNexus()manually.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?