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 🙏

© 2026 – Pkg Stats / Ryan Hefner

swan-web3-connector

v1.0.0

Published

A universal Web3 wallet connector for Vue and React applications with a user-friendly interface

Readme

Swan Web3 Connector

A universal Web3 wallet connector for Vue and React applications with a user-friendly interface. This connector provides a seamless way to interact with Web3 wallets like MetaMask in your dApp.

Features

  • 🔌 Easy wallet connection
  • 🎨 Beautiful UI components
  • 🔄 Automatic chain switching and adding
  • ✍️ Message signing support
  • 👀 Account and chain change event listeners
  • 🔗 Universal compatibility (Vue and React)
  • 🛡️ User-friendly error handling
  • 🎯 Customizable button component
  • 💫 Real-time balance updates
  • 🔍 Block explorer integration

Installation

npm install swan-web3-connector ethers

Usage

Basic Usage

import { WalletButton } from 'swan-web3-connector';

// Create and mount the button
const walletButton = new WalletButton({
  buttonText: 'Connect Wallet',
  buttonClass: 'my-wallet-button',
  onConnect: (wallet) => {
    console.log('Connected account:', wallet.account);
    console.log('Chain ID:', wallet.chainId);
    console.log('Balance:', wallet.balance);
  },
  onError: (error) => {
    console.error('Connection error:', error);
  }
});

// Mount the button to a container
walletButton.mount('#wallet-container');

Advanced Usage

import { WalletConnector } from 'swan-web3-connector';

// Create a wallet connector instance
const wallet = new WalletConnector();

// Connect to wallet
async function connectWallet() {
  try {
    const connection = await wallet.connect();
    console.log('Connected account:', connection.account);
    console.log('Current chain ID:', connection.chainId);
    console.log('Balance:', connection.balance);
  } catch (error) {
    console.error('Connection error:', error);
  }
}

// Switch or add chain
const chainInfo = {
  chainId: '0x89', // Polygon Mainnet
  chainName: 'Polygon Mainnet',
  nativeCurrency: {
    name: 'MATIC',
    symbol: 'MATIC',
    decimals: 18
  },
  rpcUrls: ['https://polygon-rpc.com'],
  blockExplorerUrls: ['https://polygonscan.com']
};

async function switchChain() {
  try {
    await wallet.checkAndSwitchChain(chainInfo);
  } catch (error) {
    console.error('Chain switch error:', error);
  }
}

// Sign a message
async function signMessage() {
  try {
    const signature = await wallet.signMessage('Hello, Web3!');
    console.log('Signature:', signature);
  } catch (error) {
    console.error('Signing error:', error);
  }
}

// Listen to account changes
wallet.on('accountChange', (account) => {
  console.log('Account changed:', account);
});

// Listen to chain changes
wallet.on('chainChange', (chainId) => {
  console.log('Chain changed:', chainId);
});

// Disconnect
wallet.disconnect();

Features in Detail

Wallet Button Component

  • Displays wallet balance and shortened address when connected
  • Automatic updates on account/chain changes
  • Customizable styling
  • Built-in popup for wallet information

Wallet Connector

  • Seamless integration with MetaMask and other Web3 wallets
  • Automatic balance updates
  • Chain management (switching/adding)
  • Message signing capabilities
  • Event handling for account and chain changes

User Interface

  • Clean and modern design
  • Responsive layout
  • Clear error messages
  • Loading states
  • Copy to clipboard functionality
  • Block explorer links

Requirements

  • A Web3 wallet (like MetaMask) installed in the browser
  • ethers.js v6.0.0 or higher

Browser Support

  • Chrome/Chromium (Latest 2 versions)
  • Firefox (Latest 2 versions)
  • Safari (Latest 2 versions)
  • Edge (Latest 2 versions)

Contributing

We welcome contributions! Please feel free to submit a Pull Request.

License

MIT

Support

For support, please open an issue in the GitHub repository or contact our support team.