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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@thebbz/siwe-ethos-react

v1.3.0

Published

React components and hooks for Sign in with Ethos authentication

Downloads

218

Readme

@thebbz/siwe-ethos-react

React components and hooks for integrating "Sign in with Ethos" authentication into your React application. Provides a beautiful, animated modal for wallet-based and social authentication.

Installation

npm install @thebbz/siwe-ethos-react
# or
yarn add @thebbz/siwe-ethos-react
# or
pnpm add @thebbz/siwe-ethos-react

Peer Dependencies

This package requires React 17+ and React DOM 17+:

npm install react react-dom

Quick Start

Using the Auth Modal

The EthosAuthModal component provides a complete authentication experience with wallet connection and social logins.

import { useState } from 'react';
import { EthosAuthModal, EthosAuthResult } from '@thebbz/siwe-ethos-react';
import '@thebbz/siwe-ethos-react/styles.css';

function App() {
  const [isModalOpen, setIsModalOpen] = useState(false);
  const [user, setUser] = useState<EthosAuthResult | null>(null);

  const handleSuccess = (result: EthosAuthResult) => {
    console.log('Authenticated:', result);
    setUser(result);
    setIsModalOpen(false);
  };

  return (
    <div>
      <button onClick={() => setIsModalOpen(true)}>
        {user ? `Signed in as ${user.profile.displayName}` : 'Sign In'}
      </button>

      <EthosAuthModal
        isOpen={isModalOpen}
        onClose={() => setIsModalOpen(false)}
        onSuccess={handleSuccess}
      />
    </div>
  );
}

Modal Props

| Prop | Type | Required | Description | |------|------|----------|-------------| | isOpen | boolean | Yes | Controls modal visibility | | onClose | () => void | Yes | Called when modal should close | | onSuccess | (result: EthosAuthResult) => void | Yes | Called on successful authentication | | baseUrl | string | No | Override the auth server URL | | showProviders | string[] | No | Filter which providers to show |

Authentication Result

The onSuccess callback receives an EthosAuthResult object:

interface EthosAuthResult {
  profile: {
    id: number;
    address: string;
    primaryAddress: string;
    displayName: string | null;
    username: string | null;
    description: string | null;
    avatar: string | null;
    score: number;
    profileUrl: string;
  };
  provider: 'wallet' | 'farcaster' | 'discord' | 'twitter' | 'telegram';
  providerData?: {
    // Provider-specific data (e.g., Farcaster FID, Discord username)
  };
}

Supported Authentication Methods

Wallet Authentication (SIWE)

  • MetaMask
  • Rabby
  • Phantom
  • Zerion
  • Coinbase Wallet
  • Brave Wallet
  • Any EIP-1193 compatible wallet

Social Authentication

  • Farcaster - QR code authentication via Warpcast
  • Discord - OAuth2 redirect flow
  • Twitter/X - OAuth2 redirect flow
  • Telegram - Widget-based authentication

Using Individual Components

You can also import individual components for more control:

import { SignInButton } from '@thebbz/siwe-ethos-react';

Hooks

useEthosAuth

Hook for managing authentication state:

import { useEthosAuth } from '@thebbz/siwe-ethos-react/hooks';

function MyComponent() {
  const { user, isLoading, signIn, signOut } = useEthosAuth();

  if (isLoading) return <div>Loading...</div>;
  if (user) return <div>Hello, {user.displayName}!</div>;
  
  return <button onClick={signIn}>Sign In</button>;
}

Styling

The modal comes with default styles. Import the CSS file to use them:

import '@thebbz/siwe-ethos-react/styles.css';

Custom Styling

You can override styles using CSS custom properties:

:root {
  --ethos-modal-bg: #1a1a1a;
  --ethos-modal-text: #ffffff;
  --ethos-primary: #2E7BC3;
  --ethos-primary-hover: #3d8bd4;
}

Or target specific classes:

.ethos-modal {
  /* Modal container styles */
}

.ethos-modal-content {
  /* Modal content styles */
}

.ethos-provider-button {
  /* Provider button styles */
}

TypeScript Support

This package is written in TypeScript and includes type definitions. All types are exported from the main package:

import type { 
  EthosAuthResult,
  EthosAuthModalProps,
  EthosProvider 
} from '@thebbz/siwe-ethos-react';

Server Configuration

The modal expects your server to have the following endpoints:

| Endpoint | Method | Description | |----------|--------|-------------| | /api/auth/nonce | GET | Generate SIWE nonce | | /api/auth/wallet/verify | POST | Verify wallet signature | | /auth/farcaster | GET | Start Farcaster auth | | /auth/farcaster/callback | GET | Farcaster polling endpoint | | /auth/discord | GET | Start Discord OAuth | | /auth/twitter | GET | Start Twitter OAuth | | /auth/telegram | GET | Start Telegram auth |

See the self-hosting documentation for setup instructions.

Example: Complete Integration

import { useState, useEffect } from 'react';
import { EthosAuthModal, EthosAuthResult } from '@thebbz/siwe-ethos-react';
import '@thebbz/siwe-ethos-react/styles.css';

function App() {
  const [isModalOpen, setIsModalOpen] = useState(false);
  const [user, setUser] = useState<EthosAuthResult | null>(null);

  // Check for stored session on mount
  useEffect(() => {
    const stored = localStorage.getItem('ethos_user');
    if (stored) {
      setUser(JSON.parse(stored));
    }
  }, []);

  const handleSuccess = (result: EthosAuthResult) => {
    setUser(result);
    localStorage.setItem('ethos_user', JSON.stringify(result));
    setIsModalOpen(false);
  };

  const handleSignOut = () => {
    setUser(null);
    localStorage.removeItem('ethos_user');
  };

  return (
    <div>
      {user ? (
        <div>
          <img src={user.profile.avatar} alt={user.profile.displayName || 'User'} />
          <span>{user.profile.displayName || user.profile.username}</span>
          <button onClick={handleSignOut}>Sign Out</button>
        </div>
      ) : (
        <button onClick={() => setIsModalOpen(true)}>
          Sign in with Ethos
        </button>
      )}

      <EthosAuthModal
        isOpen={isModalOpen}
        onClose={() => setIsModalOpen(false)}
        onSuccess={handleSuccess}
      />
    </div>
  );
}

Browser Support

  • Chrome 80+
  • Firefox 75+
  • Safari 13.1+
  • Edge 80+

Related Packages

License

MIT © thebbz