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

@cfxdevkit/react

v2.0.9

Published

React hooks over @cfxdevkit/cdk.

Readme

@cfxdevkit/react

Scope: Headless React hooks and components built on top of @cfxdevkit/cdk.

Responsibilities

  • High-level React hooks for account, balance, contract interaction, transactions, and events
  • Built on React Query for caching, background updates, and state management
  • Fully headless — no styling assumptions or UI dependencies

Dependencies

  • @cfxdevkit/cdk (required)
  • @tanstack/react-query (required peer)
  • @cfxdevkit/wallet-connect (optional peer — enables wallet-aware hooks)

Installation

npm install @cfxdevkit/react @tanstack/react-query
# Optional: for wallet integration
npm install @cfxdevkit/wallet-connect

Sub-paths

| Sub-path | Exports | |----------|---------| | . | 77 symbols | | ./account | 2 symbols | | ./balance | 10 symbols | | ./context | 6 symbols | | ./contract | 14 symbols | | ./events | 3 symbols | | ./tx | 7 symbols | | ./keystore | 34 symbols |


Core Hooks

useAccount()

Returns the currently connected account state.

const { address, chainId, status } = useAccount();

useNativeBalance(input)

Reads the native token (CFX) balance of an account.

const { data: balance, isLoading, error } = useNativeBalance({ chainId, account });

useTokenBalance(input)

Reads the ERC-20 token balance of an account.

const { data: balance, isLoading, error } = useTokenBalance({
  chainId,
  tokenAddress,
  account,
});

useTokenMetadata(input)

Fetches metadata (name, symbol, decimals) for a token.

const { data: metadata, isLoading, error } = useTokenMetadata({
  chainId,
  tokenAddress,
});

useReadContract<T>(input)

Performs a read-only call to a contract.

const { data, isLoading, error } = useReadContract({
  abi,
  address,
  functionName,
  args,
});

useReadContracts(input)

Batch read calls to multiple contracts/functions.

const { data, isLoading, error } = useReadContracts({
  contracts: [
    { abi, address, functionName, args },
    // ...
  ],
});

useSimulateContract<T>(input)

Simulates a contract call without submitting a transaction.

const { data: result, isLoading, error } = useSimulateContract({
  abi,
  address,
  functionName,
  args,
  value,
});

useWriteContract()

Returns helpers to prepare and send write transactions.

const { writeContract, isPending, error, data } = useWriteContract();

writeContract({
  abi,
  address,
  functionName,
  args,
  value,
});

useSendTransaction()

Sends a raw transaction.

const { sendTransaction, isPending, error, data } = useSendTransaction();

sendTransaction({
  to,
  value,
  data,
});

useWaitForTransaction(input)

Waits for a transaction to be confirmed.

const { data, isLoading, error } = useWaitForTransaction({
  hash,
});

useWatchEvent(input)

Watches for contract events in real time.

useWatchEvent({
  abi,
  address,
  eventName,
  onLogs: (logs) => console.log(logs),
});

Context & Providers

CfxProvider

Wraps your app to provide client, signer, and React Query context.

import { CfxProvider } from '@cfxdevkit/react';
import { QueryClient } from '@tanstack/react-query';

const queryClient = new QueryClient();

<CfxProvider
  client={client}
  signer={signer}
  queryClient={queryClient}
>
  <App />
</CfxProvider>

useClient(), useChain(), useSigner()

Access the configured client, chain config, and signer.

const client = useClient();
const chain = useChain();
const signer = useSigner();

Keystore Hooks (Optional)

Requires @cfxdevkit/wallet-connect or local keystore support.

useKeystoreLifecycle()

Manages keystore wallet lifecycle (add, unlock, sign, etc.).

const { wallets, addWallet, unlockWallet, signMessage } = useKeystoreLifecycle();

See ./keystore exports for full list of types and utilities.


Notes

  • All hooks integrate with React Query for automatic caching and refetching.
  • Hooks are typed end-to-end — full TypeScript support.
  • No UI assumptions — designed for composability with any UI library.

Usage

import { useAccount, useNativeBalance } from '@cfxdevkit/react';

function AccountBalance() {
  const { address } = useAccount();
  const { data: balance, isLoading, error } = useNativeBalance({ chainId: 1, account: address });

  if (isLoading) return <span>Loading…</span>;
  if (error) return <span>Error: {error.message}</span>;
  return <span>Balance: {balance?.toString()}</span>;
}

API Reference

See API.md for the full public surface.

Tier

Tier 0 — framework — Must not runtime-import from any higher tier.