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

oneauth-react

v1.0.7

Published

React integration for OneAuth SDK

Readme

OneAuth React SDK

Add secure authentication to your React app in minutes with just a few lines of code.

Quick Start

Get authentication working in your React app with 3 simple steps:

1. Install

npm install oneauth-react

2. Wrap your app

// src/App.jsx
import { AuthProvider, SignedIn, SignedOut, SignInButton, UserButton, useAuth } from 'oneauth-react'

function AppContent() {
  const { user } = useAuth()
  
  return (
    <>
      <header style={{ display: 'flex', justifyContent: 'space-between', padding: '1rem' }}>
        <h1>My App</h1>
        <SignedOut>
          <SignInButton />
        </SignedOut>
        <SignedIn>
          <UserButton />
        </SignedIn>
      </header>
      
      <main style={{ padding: '2rem', textAlign: 'center' }}>
        <SignedOut>
          <h2>Welcome! Please sign in to continue</h2>
        </SignedOut>
        
        <SignedIn>
          <h2>🎉 Welcome {user?.fullName || user?.email}!</h2>
        </SignedIn>
      </main>
    </>
  )
}

export default function App() {
  return (
    <AuthProvider config={{ 
      apiUrl: 'http://localhost:8080',
      authMode: 'password',
      providers: ['google', 'github']
    }}>
      <AppContent />
    </AuthProvider>
  )
}

3. That's it!

Your React app now has:

  • ✅ Google & GitHub OAuth
  • ✅ Email/password authentication
  • ✅ User sessions
  • ✅ Sign in/out components
  • ✅ Automatic user management

Features

  • 🚀 Drop-in Components - Ready-to-use authentication UI
  • 🔐 Secure by Default - Built-in security best practices
  • 🌐 OAuth Providers - GitHub, Google, and more
  • TypeScript Ready - Full TypeScript support
  • 📱 Responsive - Works on all devices

Available Components

| Component | Description | |-----------|-------------| | <SignInButton /> | Shows sign in button when user is signed out | | <UserButton /> | Shows user avatar and menu when signed in | | <SignedIn> | Only shows children when user is signed in | | <SignedOut> | Only shows children when user is signed out | | <AuthModal /> | Full authentication modal |

Configuration Options

<AuthProvider config={{
  apiUrl: 'http://localhost:8080',          // Your OneAuth server
  authMode: 'password',                     // 'password' | 'passwordless' | 'oauth'
  providers: ['google', 'github'],         // OAuth providers
  enableVerificationInput: false,           // Require email verification
  alwaysFetchUser: false,                   // Always fetch user on load
  advanced: {
    debug: false                            // Enable debug mode
  }
}}>

Get User Information

Access user data anywhere with the useAuth hook:

import { useAuth } from 'oneauth-react'

function MyComponent() {
  const { user, isAuthenticated } = useAuth()

  if (!isAuthenticated) {
    return <div>Please sign in</div>
  }

  return (
    <div>
      <h2>Welcome {user.fullName}!</h2>
      <p>Email: {user.email}</p>
      <p>Provider: {user.registeredProviderName}</p>
    </div>
  )
}

Custom Authentication Modal

Use AuthModal for a custom sign-in experience:

import { AuthModal, useAuth } from 'oneauth-react'

function MyApp() {
  const { isModalOpen, hideModal } = useAuth()
  
  return (
    <>
      <SignInButton />
      
      <AuthModal 
        isOpen={isModalOpen} 
        onClose={hideModal}
        onSuccess={hideModal}
        appName="My App"
      />
    </>
  )
}

Environment Variables

Set up your environment variables:

# .env
VITE_ONE_AUTH_SERVER_URL=http://localhost:8080

Then use in your config:

<AuthProvider config={{ 
  apiUrl: import.meta.env.VITE_ONE_AUTH_SERVER_URL || 'http://localhost:8080',
  // ... other config
}}>

TypeScript Support

Full TypeScript support out of the box:

import { useAuth, User } from 'oneauth-react'

function UserProfile() {
  const { user, isAuthenticated }: {
    user: User | null
    isAuthenticated: boolean
  } = useAuth()

  return (
    <div>
      {user?.fullName && <h2>{user.fullName}</h2>}
      <p>{user?.email}</p>
    </div>
  )
}

Examples

Check out complete examples:

Need Help?


Made with ❤️ by the OneAuth team