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

@saw-protocol/widget

v1.0.8

Published

SAWP branded React widgets for dApp connections - The MetaMask-equivalent UI for agent wallets

Readme

@saw-protocol/widget

SAWP branded React widgets for dApp connections. This is the MetaMask-equivalent UI for agent wallets — a complete, reusable widget system that dApps can integrate to connect to SAWP wallets.

Features

  • ConnectionModal — Beautiful branded modal for connection requests with permission display
  • ConnectionStatus — Persistent status widget showing connection state at the top of your dApp
  • Notification System — Toast notifications for connection events and transaction status
  • React Context Provider — Easy state management across your application
  • TypeScript Support — Fully typed for the best developer experience

Installation

npm install @saw-protocol/widget

Quick Start

Wrap your app with the SAWPProvider and add the widget components:

import { 
  SAWPProvider, 
  ConnectionModal, 
  ConnectionStatus, 
  NotificationContainer 
} from '@saw-protocol/widget';

function App() {
  return (
    <SAWPProvider walletAddress="your-wallet-address">
      <ConnectionStatus position="top-right" />
      <ConnectionModal />
      <NotificationContainer />
      
      {/* Your app content */}
      <YourApp />
    </SAWPProvider>
  );
}

Components

SAWPProvider

The context provider that manages widget state and connection logic.

<SAWPProvider 
  walletAddress="your-wallet-public-key"
  autoConnect={false}
>
  {children}
</SAWPProvider>

Props:

  • walletAddress (string, optional) — The wallet address to connect from
  • autoConnect (boolean, optional) — Whether to auto-restore previous connections

ConnectionModal

Displays connection requests with full permission details. Automatically appears when a connection is requested.

<ConnectionModal />

Features:

  • Shows dApp name, icon, and origin
  • Lists all requested permissions with descriptions
  • Security warning about trusted dApps
  • Approve/Reject actions

ConnectionStatus

Persistent widget showing connection state. Stays visible at the edge of the screen.

<ConnectionStatus position="top-right" />

Props:

  • position ('top-right' | 'top-left' | 'top-center', default: 'top-right') — Where to position the widget

Features:

  • Shows connected dApp name (truncated)
  • Animated green pulse indicator when connected
  • Dropdown with connection details and permissions
  • One-click disconnect button
  • Shows "Not Connected" state when disconnected

NotificationContainer

Displays toast notifications for connection events and errors.

<NotificationContainer />

Features:

  • Auto-dismisses after duration
  • Different colors for info/success/warning/error
  • Stacked notifications with staggered animation
  • Click to dismiss

Hooks

useSAWPWidget

Hook for dApps to initiate connections and transactions.

import { useSAWPWidget } from '@saw-protocol/widget';

function MyDapp() {
  const { 
    isConnected, 
    isConnecting,
    requestConnection, 
    disconnect 
  } = useSAWPWidget();

  const handleConnect = async () => {
    try {
      await requestConnection(
        'my-dapp-id',
        ['transfer', 'swap', 'view'],
        { name: 'My DeFi App', url: window.location.origin }
      );
    } catch (err) {
      console.error('Connection rejected:', err);
    }
  };

  return (
    <button onClick={handleConnect}>
      {isConnected ? 'Connected' : 'Connect Wallet'}
    </button>
  );
}

Complete Example

import React from 'react';
import { 
  SAWPProvider, 
  ConnectionModal, 
  ConnectionStatus, 
  NotificationContainer,
  useSAWPWidget 
} from '@saw-protocol/widget';

// Your dApp component
function MyDeFiApp() {
  const { isConnected, requestConnection, disconnect } = useSAWPWidget();

  const handleConnect = async () => {
    await requestConnection(
      'my-defi-app',
      ['transfer', 'swap', 'stake'],
      {
        name: 'My DeFi Protocol',
        url: window.location.origin,
        icon: 'https://myapp.com/icon.png'
      }
    );
  };

  return (
    <div>
      <h1>My DeFi App</h1>
      
      {isConnected ? (
        <div>
          <p>Wallet connected!</p>
          <button onClick={disconnect}>Disconnect</button>
        </div>
      ) : (
        <button onClick={handleConnect}>Connect SAWP Wallet</button>
      )}
    </div>
  );
}

// App wrapper with SAWP widgets
function App() {
  return (
    <SAWPProvider walletAddress="your-wallet-address">
      {/* Widget components */}
      <ConnectionStatus position="top-right" />
      <ConnectionModal />
      <NotificationContainer />
      
      {/* Your app */}
      <MyDeFiApp />
    </SAWPProvider>
  );
}

export default App;

Styling

The widgets come with built-in SAWP branding (purple/green dark theme). All styles are inline and scoped to components — no external CSS files required.

Default Theme Colors

  • Primary: #9945ff (purple)
  • Secondary: #14f195 (green)
  • Background: #12121a (dark)
  • Surface: #1a1a25 (card backgrounds)
  • Border: #2a2a3a (subtle borders)

Architecture

┌─────────────────────────────────────┐
│           Your dApp                 │
│  ┌───────────────────────────────┐  │
│  │   useSAWPWidget() hook        │  │
│  │   - requestConnection()       │  │
│  │   - requestTransaction()      │  │
│  └───────────────────────────────┘  │
└─────────────────┬───────────────────┘
                  │
┌─────────────────▼───────────────────┐
│        SAWPProvider Context         │
│  ┌───────────────────────────────┐  │
│  │   WalletConnector instance    │  │
│  │   Connection state management │  │
│  │   Notification queue          │  │
│  └───────────────────────────────┘  │
└─────────────────┬───────────────────┘
                  │
    ┌─────────────┼─────────────┐
    │             │             │
┌───▼───┐  ┌─────▼──────┐ ┌────▼────┐
│Modal  │  │Status      │ │Notif.   │
│Widget │  │Widget      │ │Container│
└───────┘  └────────────┘ └─────────┘

License

MIT