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

@phila/sso-react

v0.0.9

Published

React adapter for @phila/sso-core

Readme

@phila/sso-react

React adapter for @phila/sso-core. Provides context providers and hooks for Azure AD B2C authentication.

Installation

pnpm add @phila/sso-react @phila/sso-core @azure/msal-browser

Quick Start (Vite + B2C)

The B2CSSOProvider reads VITE_SSO_* environment variables automatically:

VITE_SSO_CLIENT_ID=your-client-id
VITE_SSO_TENANT=YourTenant
VITE_SSO_AUTHORITY_DOMAIN=YourTenant.b2clogin.com
VITE_SSO_REDIRECT_URI=http://localhost:3000
// App.tsx
import { B2CSSOProvider, useAuth } from "@phila/sso-react";

function AuthContent() {
  const { isAuthenticated, userName, authReady, signIn, signOut } = useAuth();

  if (!authReady) return <div>Loading...</div>;

  if (isAuthenticated) {
    return (
      <div>
        <p>Welcome, {userName}</p>
        <button onClick={() => signOut()}>Sign out</button>
      </div>
    );
  }

  return <button onClick={() => signIn()}>Sign in</button>;
}

export default function App() {
  return (
    <B2CSSOProvider>
      <AuthContent />
    </B2CSSOProvider>
  );
}

Advanced Setup

For full control over the provider configuration:

import { SSOProvider } from "@phila/sso-react";
import { B2CProvider } from "@phila/sso-core";

function App() {
  return (
    <SSOProvider
      config={{
        provider: new B2CProvider({
          clientId: "your-client-id",
          b2cEnvironment: "YourTenant",
          authorityDomain: "YourTenant.b2clogin.com",
          redirectUri: "http://localhost:3000",
          apiScopes: ["https://YourTenant.onmicrosoft.com/api/read"],
          policies: {
            signUpSignIn: "B2C_1A_SIGNUP_SIGNIN",
            signInOnly: "B2C_1A_AD_SIGNIN_ONLY",
            resetPassword: "B2C_1A_PASSWORDRESET",
          },
        }),
        debug: true,
      }}
    >
      <AuthContent />
    </SSOProvider>
  );
}

SSOProvider Props

interface SSOProviderProps {
  config: SSOClientConfig;
  children: ReactNode;
}

B2CSSOProvider Props

interface B2CSSOProviderProps {
  children: ReactNode;
  signInPolicy?: string; // default: "B2C_1A_AD_SIGNIN_ONLY"
  resetPasswordPolicy?: string; // default: "B2C_1A_PASSWORDRESET"
  debug?: boolean; // default: import.meta.env.DEV
}

Hooks

useAuth()

Primary hook for authentication. Must be called within an SSOProvider or B2CSSOProvider.

State:

| Property | Type | Description | | ----------------- | --------------------- | ------------------------------ | | isAuthenticated | boolean | User is signed in | | isLoading | boolean | Auth operation in progress | | user | AccountInfo \| null | MSAL account info | | token | string \| null | Current access token | | error | Error \| null | Last auth error | | activePolicy | string \| null | Active B2C policy | | authReady | boolean | Initialization complete | | userName | string \| null | Display name from token claims |

Actions:

| Method | Returns | Description | | ------------------------------ | ------------------------- | -------------------------------- | | signIn(options?) | Promise<void> | Start sign-in flow | | signInCityEmployee(options?) | Promise<void> | Sign in with sign-in-only policy | | signOut(options?) | Promise<void> | Sign out | | forgotPassword() | Promise<void> | Start password reset | | acquireToken(options?) | Promise<string \| null> | Get access token |

Utilities:

| Method | Returns | Description | | --------------- | --------- | ------------------------------------------------------- | | hasRole(role) | boolean | Check user role from roles or extension_Roles claim |

useSSOClient()

Returns the raw SSOClient instance for advanced use cases.

const client = useSSOClient();
client.events.on("auth:tokenAcquired", token => {
  /* ... */
});

License

MIT