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

@unified-api/react-authentication

v1.0.0

Published

React component for Unified API authentication

Downloads

8

Readme

@unified-api/react-authentication

React component for Unified API authentication / SSO. This component provides a seamless OAuth authentication experience for various providers through the Unified API platform.

Installation

Using npm:

npm install @unified-api/react-authentication

Using yarn:

yarn add @unified-api/react-authentication

Usage

import React from 'react';
import UnifiedAuthentication from '@unified-api/react-authentication';

function App() {
  const handleSuccess = (data) => {
    console.log('Authentication successful:', data);
  };

  const handleFailure = (error) => {
    console.error('Authentication failed:', error);
  };

  return (
    <div>
      <UnifiedAuthentication
        workspace_id="your-workspace-id"
        title="Connect your accounts"
        description="Choose a service to authenticate with"
        onSuccess={handleSuccess}
        onFailure={handleFailure}
      />
    </div>
  );
}

Props

Required Props

| Prop | Type | Description | |------|------|-------------| | workspace_id | string | Required. Your Unified API workspace ID for authentication |

Optional Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | dc | 'us' \| 'eu' \| 'au' | 'us' | Data center region for API calls | | environment | string | undefined | Environment setting for the authentication flow | | title | string | undefined | Title displayed above authentication options | | description | string | undefined | Description text displayed below the title | | success_url | string | window.location.href | URL to redirect to after successful authentication | | failure_url | string | window.location.href | URL to redirect to after failed authentication | | state | string | undefined | State parameter that will be returned to success/failure URLs | | pretext | string | 'Sign in with' | Prefix text for authentication buttons (e.g., "Continue with", "Login via") | | include_text | boolean | true | Whether to display text labels on authentication buttons | | include_icon | boolean | true | Whether to display provider icons on authentication buttons | | className | string | '' | Custom CSS class name for the component container | | style | React.CSSProperties | undefined | Inline styles for the component container | | onSuccess | (data: { name?: string; emails?: string[] }) => void | undefined | Callback function called when authentication succeeds | | onFailure | (error: Error) => void | undefined | Callback function called when authentication fails |

Examples

Basic Usage

<UnifiedAuthentication workspace_id="ws_1234567890" />

With Custom Title and Description

<UnifiedAuthentication
  workspace_id="ws_1234567890"
  title="Connect Your Account"
  description="Link your external accounts to sync data"
  pretext="Continue with"
/>

With Success/Failure Callbacks

<UnifiedAuthentication
  workspace_id="ws_1234567890"
  onSuccess={(data) => {
    console.log('User authenticated:', data.name, data.emails);
    // Handle successful authentication
  }}
  onFailure={(error) => {
    console.error('Authentication failed:', error.message);
    // Handle authentication failure
  }}
/>

Custom Styling

<UnifiedAuthentication
  workspace_id="ws_1234567890"
  className="my-auth-component"
  style={{ 
    maxWidth: '300px',
    padding: '24px',
    border: '1px solid #e1e5e9',
    borderRadius: '12px'
  }}
/>

Different Data Center

<UnifiedAuthentication
  workspace_id="ws_1234567890"
  dc="eu"  // Use European data center
/>

Minimal Button Style

<UnifiedAuthentication
  workspace_id="ws_1234567890"
  include_text={false}  // Only show icons
  pretext=""
/>

With Custom URLs

<UnifiedAuthentication
  workspace_id="ws_1234567890"
  success_url="https://myapp.com/auth/success"
  failure_url="https://myapp.com/auth/error"
  state="custom_state_data"
/>

Authentication Flow

  1. Component fetches available authentication providers from Unified API
  2. User clicks on a provider button
  3. User is redirected to the provider's OAuth flow
  4. After authentication, user is redirected back to your success_url or failure_url
  5. On success, a JWT token containing user info is included in the URL parameters
  6. The onSuccess callback is triggered with decoded user data

Styling

The component includes default styles that work well out of the box, with support for both light and dark modes. You can customize the appearance using:

  • CSS classes (see the component's CSS for available class names)
  • The className prop for container-level styling
  • The style prop for inline styles
  • CSS custom properties for theme customization

CSS Classes

  • .unified-authentication - Main container
  • .unified-auth-title - Title element
  • .unified-auth-description - Description text
  • .unified-auth-providers - Provider buttons container
  • .unified-auth-button - Individual provider buttons
  • .unified-auth-icon - Provider icons
  • .unified-auth-text - Button text
  • .unified-auth-loading - Loading state container
  • .unified-auth-error - Error state container

TypeScript

This package includes TypeScript definitions. All props are fully typed, and the component exports its prop types:

import UnifiedAuthentication, { 
  UnifiedAuthenticationProps,
  DataCenter 
} from '@unified-api/react-authentication';

Requirements

  • React 16.8.0 or higher
  • Modern browser with fetch API support

License

MIT