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

@wangjinbao/wallet-connect

v0.1.13

Published

A React wallet connection library supporting MetaMask, OKX Wallet, Phantom, and Coinbase Wallet

Downloads

1,341

Readme

@wangjinbao/wallet-connect

A React + TypeScript wallet connection library supporting MetaMask, OKX Wallet, Phantom, and Coinbase Wallet.

Features

  • 🔌 Easy wallet connection with multiple wallet support
  • 🔄 Automatic chain switching (bidirectional sync)
  • 🎨 Beautiful UI components with TailwindCSS
  • 📱 Responsive and accessible
  • 🔒 Type-safe with TypeScript
  • 🎯 Based on MetaMask JSON-RPC API standard (EIP-1193)
  • 💾 Auto-reconnect on page refresh

Supported Wallets

  • MetaMask
  • OKX Wallet
  • Phantom (EVM)
  • Coinbase Wallet

Installation

npm install @wangjinbao/wallet-connect

Quick Start

1. Import Styles

Import the component styles in your app's entry point:

import "@wangjinbao/wallet-connect/styles.css";

2. Wrap Your App with WalletProvider

import { WalletProvider, mainnet, sepolia } from "@wangjinbao/wallet-connect";

function App() {
  return (
    <WalletProvider
      config={{
        chains: [mainnet, sepolia],
        autoConnect: true,
      }}
    >
      <YourApp />
    </WalletProvider>
  );
}

3. Use the ConnectButton Component

import { ConnectButton } from "@wangjinbao/wallet-connect";

function YourApp() {
  return (
    <div>
      <ConnectButton />
    </div>
  );
}

4. Access Wallet State

import { useWallet } from "@wangjinbao/wallet-connect";

function MyComponent() {
  const { state, switchChain } = useWallet();

  return (
    <div>
      {state.isConnected ? (
        <div>
          <p>Connected to: {state.wallet?.name}</p>
          <p>Account: {state.account}</p>
          <p>Chain ID: {state.chainId}</p>
        </div>
      ) : (
        <p>Not connected</p>
      )}
    </div>
  );
}

API Reference

WalletProvider

The main provider component that manages wallet state.

Props:

  • config.chains - Array of supported chains
  • config.autoConnect - Enable auto-reconnect (default: true)
  • config.appName - Your app name (optional)

ConnectButton

Pre-built button component with wallet selection modal and chain switcher.

useWallet Hook

Hook to access wallet context.

Returns:

{
  state: {
    isConnected: boolean;
    account: string | null;
    chainId: string | null;
    wallet: WalletInfo | null;
  };
  connect: (walletId: string) => Promise<void>;
  disconnect: () => Promise<void>;
  switchChain: (chainId: string) => Promise<void>;
  availableWallets: WalletInfo[];
  supportedChains: Chain[];
}

Custom Chain Configuration

import { Chain } from "@wangjinbao/wallet-connect";

const myCustomChain: Chain = {
  chainId: "0x89", // Polygon
  chainName: "Polygon Mainnet",
  nativeCurrency: {
    name: "MATIC",
    symbol: "MATIC",
    decimals: 18,
  },
  rpcUrls: ["https://polygon-rpc.com"],
  blockExplorerUrls: ["https://polygonscan.com"],
};

Advanced Usage

Direct Wallet Access

import { MetaMaskWallet } from "@wangjinbao/wallet-connect";

const wallet = new MetaMaskWallet();

if (wallet.isInstalled()) {
  const accounts = await wallet.connect();
  const chainId = await wallet.getChainId();
}

Custom Styling

The library uses TailwindCSS for styling. All classes are prefixed with wangjinbao- to avoid conflicts. You can override styles by targeting these classes in your CSS.

TypeScript

This library is written in TypeScript and includes type definitions. All types are exported for your use:

import type {
  Chain,
  WalletInfo,
  WalletState,
  WalletContextValue,
  EthereumProvider,
} from "@wangjinbao/wallet-connect";

License

MIT