skills/nexus-sdk-setup/SKILL.md
Set up and initialize Nexus SDK in any JS/TS frontend project. Use when configuring wallet provider, SDK instance lifecycle, network selection, or adding a minimal wallet connection path.
npx skillsauth add availproject/nexus-sdk nexus-sdk-setupInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
npm install @avail-project/nexus-corepnpm add @avail-project/nexus-coreyarn add @avail-project/nexus-corerequest method.const provider = (window as any).ethereumnew NexusSDK({ network, debug, siweChain }).network:
'mainnet' or 'testnet' to use default endpoints.NetworkConfig to use custom endpoints.debug?: boolean to enable verbose SDK logging.siweChain?: number to set the SIWE chain id (if you use SIWE).sdk.isInitialized() to avoid re-init.import { NexusSDK, type EthereumProvider } from '@avail-project/nexus-core';
const sdk = new NexusSDK({ network: 'mainnet' });
export async function initNexus(provider: EthereumProvider) {
if (sdk.isInitialized()) return sdk;
if (!provider || typeof provider.request !== 'function') {
throw new Error('Invalid EIP-1193 provider');
}
await sdk.initialize(provider);
return sdk;
}
connector.getProvider() on desktop and a walletClient.request wrapper on mobile.import { NexusSDK, type EthereumProvider } from '@avail-project/nexus-core';
import { useAccount, useConnectorClient } from 'wagmi';
const sdk = new NexusSDK({ network: 'mainnet', debug: false });
async function initFromWalletKit(isMobile: boolean) {
const { connector } = useAccount();
const { data: walletClient } = useConnectorClient();
const mobileProvider =
walletClient &&
({
request: (args: unknown) => walletClient.request(args as never),
} as EthereumProvider);
const desktopProvider = await connector?.getProvider();
const effectiveProvider = isMobile ? mobileProvider : desktopProvider;
if (!effectiveProvider || typeof effectiveProvider.request !== 'function') {
throw new Error('Invalid EIP-1193 provider from wallet kit');
}
if (!sdk.isInitialized()) {
await sdk.initialize(effectiveProvider);
}
return sdk;
}
await sdk.deinit().await sdk.setEVMProvider(provider)sdk.hasEvmProvider to confirm.useEffect or dynamic import) to avoid SSR issues.accountsChanged..on/.removeListener, call:
sdk.triggerAccountChange() after the wallet address changes.sdk.initialize in try/catch.SDK_INIT_STATE_NOT_EXPECTED, call await sdk.deinit() and retry.WALLET_NOT_CONNECTED or CONNECT_ACCOUNT_FAILED, prompt user to reconnect.development
Implement swapWithExactIn, swapWithExactOut, and swapAndExecute flows with Nexus SDK. Use when wiring swap operations, swap intent hooks, or swap event progress updates.
development
End-to-end integration guidance for Avail Nexus SDK in any JS/TS frontend project (React/Next/Vite/etc). Use when asked to integrate, initialize, or wire Nexus SDK flows (bridge, transfer, execute, swap), hooks, events, balances, supported chains/tokens, or formatter utilities.
development
Configure Nexus SDK intent/allowance/swap intent hooks and event streaming. Use when integrating approval flows, intent previews, or real-time progress events (NEXUS_EVENTS).
development
Implement bridge, bridgeAndTransfer, bridgeAndExecute, and execute flows with Nexus SDK. Use when wiring cross-chain bridge and execution operations, simulations, or max-amount checks.