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

@agentfish/react

v0.4.1

Published

React SDK for AgentFish - embedded non-custodial wallets with x402 payments

Downloads

45

Readme

@agentfish/react

React SDK for AgentFish - embedded non-custodial wallets with seamless x402 payment handling.

Overview

AgentFish React provides a complete authentication and wallet management solution for React applications. It enables:

  • Embedded wallets - Non-custodial, secure key management
  • Multiple auth methods - Email magic link, Passkey (WebAuthn), External Wallets (Phantom, MetaMask, etc.)
  • Automatic x402 payments - Seamless payment handling for AI APIs
  • Customizable UI - Full theming support with CSS variables
  • Zero configuration - No external service setup required

Installation

npm install @agentfish/react
# or
pnpm add @agentfish/react

Quick Start

import { AgentFishProvider, SignIn, WalletButton, useAuth } from '@agentfish/react';
import '@agentfish/react/styles.css';

function App() {
  return (
    <AgentFishProvider>
      <YourApp />
    </AgentFishProvider>
  );
}

function YourApp() {
  const { isOnboarded } = useAuth();

  // isOnboarded = authenticated + has a wallet
  // If authenticated without a wallet, the provider auto-shows a wallet creation modal
  return (
    <div>
      {isOnboarded ? (
        <WalletButton />
      ) : (
        <SignIn providers={['email', 'passkey', 'wallet']} />
      )}
    </div>
  );
}

Components

<AgentFishProvider>

Wraps your app with AgentFish context. Required at the root level.

<AgentFishProvider
  config={{
    // Optional: API key for server wallet authorization
    apiKey: 'agentfish_live_xxx',
    
    // x402 Configuration (optional)
    facilitatorUrl: string,   // Custom x402 facilitator (default: AgentFish)
    x402Version: 1 | 2,       // x402 protocol version (default: 1)
    
    // Other options
    rpcUrl: string,           // Solana RPC URL
    theme: ThemeConfig,       // UI customization
  }}
>
  {children}
</AgentFishProvider>

Note: No configuration required for basic usage! The SDK automatically handles authentication and wallet management.

<SignIn>

Authentication component with support for email, passkey, and external wallet auth.

// Uncontrolled mode - shows built-in button
<SignIn 
  providers={['email', 'passkey', 'wallet']}
  onSuccess={(wallet) => console.log('Authenticated!', wallet.address)}
  onError={(error) => console.error(error)}
/>

// Controlled mode - use your own button
const [isOpen, setIsOpen] = useState(false);

<button onClick={() => setIsOpen(true)}>Sign In</button>
<SignIn 
  isOpen={isOpen}
  onOpenChange={setIsOpen}
  providers={['email', 'wallet']}
  onSuccess={(wallet) => console.log('Authenticated!')}
/>

Props:

  • providers - Array of auth methods: 'email', 'passkey', 'wallet'
  • isOpen / onOpenChange - Controlled mode for custom trigger buttons
  • onSuccess - Callback with wallet address on successful auth
  • onError - Error callback
  • className / classNames - Custom styling

<WalletButton>

Displays wallet info with a dropdown for balance, address, and actions.

<WalletButton 
  variant="full"           // 'full' | 'compact' | 'icon-only'
  showBalance={true}       // Show balance in button
  dropdownAlign="right"    // 'left' | 'right'
  dropdownDirection="down" // 'up' | 'down'
  onAddFunds={() => {}}    // Callback when add funds clicked
  onDisconnect={() => {}}  // Callback on disconnect
/>

<AddFundsModal>

QR code modal for funding the wallet.

<AddFundsModal 
  isOpen={true}
  onClose={() => setIsOpen(false)}
  address="wallet-address"
/>

Hooks

useAuth()

Authentication state and actions.

const { 
  isAuthenticated,    // boolean - user has a valid session
  isOnboarded,        // boolean - user is authenticated AND has a wallet
  needsWalletSetup,   // boolean - user is authenticated but has no wallet yet
  isLoading,          // boolean
  user,               // User | null
  signOut,            // () => Promise<void>
} = useAuth();

Onboarding gate: When a user authenticates but doesn't have a wallet yet, the provider automatically displays a paywall modal prompting them to create one. Use isOnboarded instead of isAuthenticated to gate access to features that require a wallet.

useWallet()

Wallet information.

const { 
  wallet,           // Wallet | null
  balance,          // number (USDC)
  address,          // string | null
  refreshWallet,    // () => Promise<void>
} = useWallet();

useAgentFish()

Full context access including x402 payment functions.

const { 
  // Auth
  isAuthenticated,
  user,
  wallet,
  
  // Payments
  fetch,            // x402-aware fetch wrapper
  pay,              // Manual payment function
  
  // Wallet
  balance,
  refreshWallet,
  getPayments,
} = useAgentFish();

// x402-aware fetch - automatically handles 402 Payment Required
const response = await fetch('https://ai-api.com/chat', {
  method: 'POST',
  body: JSON.stringify({ message: 'Hello' }),
  maxPayment: 1.00, // Max $1 USDC
});

// Manual payment
const { signature } = await pay(0.50, 'https://merchant.com', 'merchant-address');

Theming

CSS Variables

Import the base styles and override CSS variables:

@import '@agentfish/react/styles.css';

:root {
  --af-primary: #0EA5E9;
  --af-primary-hover: #0284C7;
  --af-background: #0f0f1a;
  --af-surface: #1a1a2e;
  --af-border: #2d2d44;
  --af-text: #ffffff;
  --af-text-muted: #9ca3af;
  --af-radius: 12px;
}

Theme Config

Pass theme configuration to the provider:

<AgentFishProvider
  config={{
    theme: {
      mode: 'dark', // 'light' | 'dark'
      colors: {
        primary: '#0EA5E9',
        primaryHover: '#0284C7',
        background: '#0f0f1a',
        surface: '#1a1a2e',
        border: '#2d2d44',
        text: '#ffffff',
        textMuted: '#9ca3af',
      },
      radius: '12px',
      fontFamily: 'Inter, sans-serif',
    },
  }}
>

x402 Payment Protocol

The SDK supports both x402 v1 and v2 protocols:

  • v1 (default): Uses X-PAYMENT header, JSON body for 402 responses
  • v2: Uses PAYMENT-SIGNATURE header, PAYMENT-REQUIRED header

Facilitator Configuration

By default, AgentFish acts as the x402 facilitator - handling payment settlement automatically. You can optionally use an external facilitator:

<AgentFishProvider
  config={{
    // Use AgentFish as facilitator (default - recommended)
    // No facilitatorUrl needed
    
    // OR use external facilitator
    facilitatorUrl: 'https://x402.payai.network',
    
    x402Version: 1, // Protocol version
  }}
>

When to use an external facilitator:

  • You're building a payment network with multiple providers
  • You need custom payment routing logic
  • You want to use a third-party settlement service

Supported Wallets

External Wallet Auth

  • Solana: Phantom, Solflare
  • EVM: MetaMask, Coinbase Wallet

The SDK detects installed wallets and shows appropriate options.

TypeScript

Full TypeScript support with exported types:

import type {
  AgentFishConfig,
  ThemeConfig,
  Wallet,
  User,
  Payment,
  SignInProps,
  WalletButtonProps,
  X402Version,
} from '@agentfish/react';

Development

# Build
pnpm nx build @agentfish/react

# Type check
pnpm nx typecheck @agentfish/react

# Test
pnpm nx test @agentfish/react

License

MIT