WalletConnectButton

The primary component for connecting Web3 wallets with support for 15+ wallet providers.

The WalletConnectButton is the essential component for Web3 authentication, providing a seamless wallet connection experience across all major wallet providers and blockchain networks.

Features

  • Universal Wallet Support: MetaMask, WalletConnect, Coinbase Wallet, Rainbow, and 15+ more
  • Multi-Chain Compatible: Ethereum, Polygon, Arbitrum, Optimism, Solana, and others
  • Mobile Optimized: Deep-linking and QR codes for mobile wallet apps
  • Customizable UI: Multiple variants, sizes, and styling options
  • Connection State: Built-in loading, error, and success states

Basic Usage

<template>
  <div class="space-y-4">
    <WalletConnectButton
      @connect="handleConnect"
      @disconnect="handleDisconnect"
    />

    <div v-if="connected" class="flex items-center gap-2 text-sm font-mono">
      <span>{{ walletAddress }}</span>
    </div>
  </div>
</template>

<script setup>
const connected = ref(false)
const walletAddress = ref('')

const handleConnect = (wallet) => {
  connected.value = true
  walletAddress.value = wallet.address
  console.log('Connected to:', wallet.name)
}

const handleDisconnect = () => {
  connected.value = false
  walletAddress.value = ''
}
</script>

Props

PropTypeDefaultDescription
variant'default' | 'outline' | 'ghost' | 'gradient''default'Button visual style
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'Button size
loadingbooleanfalseShow loading state
disabledbooleanfalseDisable the button
supportedChainsstring[]['ethereum']Supported blockchain networks
defaultChainstring'ethereum'Default chain to connect to
walletConnectProjectIdstringundefinedWalletConnect Cloud project ID
hideWhenConnectedbooleanfalseHide button when wallet is connected

Events

EventPayloadDescription
@connectWalletInfoFired when wallet successfully connects
@disconnectvoidFired when wallet disconnects
@errorErrorFired when connection fails
@chainChangedstringFired when user switches chains

Advanced Usage

Multi-Chain Setup

<template>
  <WalletConnectButton
    :supported-chains="chains"
    default-chain="ethereum"
    @connect="handleConnect"
    @chain-changed="handleChainChange"
  />
</template>

<script setup>
const chains = ['ethereum', 'polygon', 'arbitrum', 'optimism']

const handleConnect = (wallet) => {
  console.log(`Connected to ${wallet.name} on ${wallet.chain}`)
}

const handleChainChange = (newChain) => {
  console.log(`Switched to ${newChain}`)
}
</script>

Custom Styling

<template>
  <div class="space-y-4">
    <WalletConnectButton
      variant="gradient"
      size="lg"
      class="w-full"
    />

    <WalletConnectButton
      variant="outline"
      size="sm"
      class="border-fuchsia-500 text-fuchsia-600"
    />
  </div>
</template>

With Loading State

<template>
  <WalletConnectButton
    :loading="connecting"
    :disabled="connecting"
    @connect="handleConnect"
  />
</template>

<script setup>
const connecting = ref(false)

const handleConnect = async (wallet) => {
  connecting.value = true
  try {
    // Perform additional setup
    await setupUserProfile(wallet)
  } finally {
    connecting.value = false
  }
}
</script>

Wallet Provider Support

ProviderTypeMobileDesktop
MetaMaskBrowser Extension
WalletConnectProtocol
Coinbase WalletApp/Extension
RainbowMobile App
Trust WalletMobile App
PhantomSolana

Configuration

Global Setup

// plugins/supaweb3.client.ts
export default defineNuxtPlugin(() => {
  const supaweb3 = createSupaWeb3({
    walletConnect: {
      projectId: 'your-project-id',
      chains: ['ethereum', 'polygon']
    },
    defaultChain: 'ethereum'
  })

  return {
    provide: { supaweb3 }
  }
})

Environment Variables

# .env
WALLETCONNECT_PROJECT_ID=your_project_id
DEFAULT_CHAIN=ethereum

Troubleshooting

Common Issues

Connection Fails

  • Ensure WalletConnect project ID is set
  • Check that the requested chain is supported
  • Verify wallet app is installed on mobile

Chain Switching

  • Some wallets require manual chain switching
  • Provide clear instructions to users
  • Handle chain mismatch errors gracefully

Mobile Deep-linking

  • Test on actual devices, not simulators
  • Ensure proper URL schemes are configured
  • Provide fallback QR codes

The Night Project Built with Nuxt UI • © 2025