npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@meshconnect/uwc-react

v0.3.21

Published

React hooks and components for Universal Wallet Connector

Downloads

1,597

Readme

@meshconnect/uwc-react

React hooks and providers for Universal Wallet Connector.

Installation

npm install @meshconnect/uwc-react @meshconnect/uwc-core @meshconnect/uwc-types @meshconnect/uwc-constants

Usage

Setup Provider

import { ConnectionProvider } from '@meshconnect/uwc-react'
import { mainnetNetwork, baseNetwork } from '@meshconnect/uwc-constants'
import type { WalletMetadata } from '@meshconnect/uwc-types'

// Define your wallets
const wallets: WalletMetadata[] = [
  {
    id: 'metamask',
    name: 'MetaMask',
    metadata: {
      icon: 'https://...',
      description: 'Connect with MetaMask'
    },
    extensionInjectedProvider: {
      supportedNetworkIds: ['eip155:1', 'eip155:8453'],
      // ... other config
    },
    walletConnectProvider: {
      supportedNetworkIds: ['eip155:1', 'eip155:8453']
    }
  }
]

function App() {
  return (
    <ConnectionProvider
      networks={[mainnetNetwork, baseNetwork]}
      wallets={wallets}
      usingIntegratedBrowser={false}
    >
      {/* Your app */}
    </ConnectionProvider>
  )
}

Using Hooks

useConnection

Connect to a specific wallet with different connection modes:

import { useConnection } from '@meshconnect/uwc-react'

function WalletButton({ walletId }: { walletId: string }) {
  const { walletConnect, injected } = useConnection(walletId)
  
  return (
    <div>
      {/* Injected connection */}
      <button 
        onClick={() => injected.connect()}
        disabled={injected.isLoading}
      >
        {injected.isLoading ? 'Connecting...' : 'Connect with Browser'}
      </button>
      
      {/* WalletConnect connection */}
      <button 
        onClick={() => walletConnect.connect()}
        disabled={walletConnect.isLoading}
      >
        {walletConnect.isLoading ? 'Connecting...' : 'Connect with WalletConnect'}
      </button>
      
      {/* Show QR code URI when available */}
      {walletConnect.connectionURI && (
        <div>Connection URI: {walletConnect.connectionURI}</div>
      )}
    </div>
  )
}

useSwitchNetwork

Switch between available networks:

import { useSwitchNetwork, useSession } from '@meshconnect/uwc-react'

function NetworkSwitcher() {
  const { switchNetwork, isLoading, isWaitingForUserApproval } = useSwitchNetwork()
  const session = useSession()
  
  return (
    <div>
      <p>Current network: {session.activeNetwork?.name}</p>
      
      <button 
        onClick={() => switchNetwork('eip155:1')}
        disabled={isLoading}
      >
        {isWaitingForUserApproval 
          ? 'Waiting for approval...' 
          : isLoading 
          ? 'Switching...' 
          : 'Switch to Mainnet'}
      </button>
    </div>
  )
}

useDisconnect

Disconnect from the current wallet:

import { useDisconnect } from '@meshconnect/uwc-react'

function DisconnectButton() {
  const { disconnect, isLoading } = useDisconnect()
  
  return (
    <button onClick={disconnect} disabled={isLoading}>
      {isLoading ? 'Disconnecting...' : 'Disconnect'}
    </button>
  )
}

useSession

Access the current session state:

import { useSession } from '@meshconnect/uwc-react'

function SessionInfo() {
  const session = useSession()
  
  return (
    <div>
      <p>Connected: {session.activeAddress ? 'Yes' : 'No'}</p>
      <p>Address: {session.activeAddress}</p>
      <p>Network: {session.activeNetwork?.name}</p>
      <p>Wallet: {session.activeWallet?.name}</p>
      <p>Mode: {session.connectionMode}</p>
    </div>
  )
}

useWallets and useNetworks

Access available wallets and networks:

import { useWallets, useNetworks } from '@meshconnect/uwc-react'

function WalletList() {
  const wallets = useWallets()
  const networks = useNetworks()
  
  return (
    <div>
      <h3>Available Wallets:</h3>
      {wallets.map(wallet => (
        <div key={wallet.id}>
          {wallet.name}
        </div>
      ))}
      
      <h3>Available Networks:</h3>
      {networks.map(network => (
        <div key={network.id}>
          {network.name}
        </div>
      ))}
    </div>
  )
}

API Reference

ConnectionProvider

Provider component that initializes the UniversalWalletConnector and provides it to child components.

Props:

  • networks: Network[] - Array of supported networks
  • wallets: WalletMetadata[] - Array of supported wallets
  • usingIntegratedBrowser?: boolean - Whether using integrated browser (default: false)
  • walletConnectConfig?: WalletConnectConfig - Optional WalletConnect configuration

Hooks

useConnection(walletId: string)

Returns an object with connection methods for both injected and WalletConnect modes.

useSwitchNetwork()

Returns methods and state for switching networks.

useDisconnect()

Returns disconnect method and loading state.

useSession()

Returns the current session state.

useWallets()

Returns the list of available wallets.

useNetworks()

Returns the list of available networks.