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

auth-mini-react-components

v0.6.1

Published

Auth Mini sign-in and account-security controls for React and shadcn/ui.

Downloads

1,104

Readme

auth-mini-react-components

auth-mini-react-components provides a shared Auth Mini session for React and shadcn/ui. AuthMiniProvider owns Browser SDK persistence and redirect handling once for the whole application. Its useAuthMini hook makes the current session available anywhere below the Provider, while AuthMiniButton renders the standard sign-in and account-security control.

Install

npm install auth-mini auth-mini-react-components

AuthMiniButton composes the standard shadcn Button, Dialog, and Alert components. It does not ship a stylesheet: it reuses the application's shadcn/Tailwind theme and semantic tokens. Add the package output to Tailwind's content sources so its shadcn utility classes are generated.

import {
  AuthMiniButton,
  AuthMiniProvider,
  useAuthMini,
} from 'auth-mini-react-components';
// tailwind.config.ts
export default {
  content: [
    './src/**/*.{ts,tsx}',
    './node_modules/auth-mini-react-components/dist/**/*.js',
  ],
};

Usage

function App() {
  return (
    <AuthMiniProvider
      autoRedirectToLogin={false}
      authMiniBaseUrl="https://auth.example.com"
    >
      <Page />
      <AuthMiniButton lang="en" />
    </AuthMiniProvider>
  );
}

function Page() {
  const { session, isAuthenticated, signOut } = useAuthMini();

  // Read session.accessToken at request time. Browser SDK refreshes it.
  return isAuthenticated ? (
    <button onClick={() => void signOut()}>
      {session?.sessionId}: Sign out
    </button>
  ) : null;
}

For Tailwind v4, add the package output as a source in your application CSS:

@source "../node_modules/auth-mini-react-components/dist";

On an ordinary HTTPS app, the Provider uses the current URL as the callback by default. Override callbackUrl only when the app has a dedicated callback route. audience is for a loopback development callback only; do not pass it for an HTTPS callback because Auth Mini derives that audience from the callback hostname.

Every Provider must set autoRedirectToLogin explicitly. Set it to true for an application whose every route requires a signed-in user. After Auth Mini has processed a possible login callback, the Provider redirects an anonymous browser session directly to the Auth Mini login page. Set it to false when the application offers anonymous pages and should decide when to call signIn().

<AuthMiniProvider
  autoRedirectToLogin
  authMiniBaseUrl="https://auth.example.com"
>
  <App />
</AuthMiniProvider>
<AuthMiniProvider
  autoRedirectToLogin={false}
  authMiniBaseUrl="https://auth.example.com"
  callbackUrl="http://localhost:5173/auth/callback"
  audience="app.example.com"
>
  <App />
</AuthMiniProvider>

The Provider supports ordinary fragment callbacks and HashRouter callback queries. It creates and verifies a one-time state value before asking Browser SDK to persist the token response. Callback tokens are removed from the address bar immediately and never rendered. It is the only component that initializes the Browser SDK, subscribes to session changes, or adopts a callback.

Security settings

The signed-in User IconButton opens a dialog that displays a copyable UID with a dedicated copy IconButton and confirmation toast, an Add passkey action, a link to Auth Mini's real sign-in-method management page at /web/#/, and the destructive sign-out action. Add passkey opens the dedicated registration popup using the Provider configuration. The management page opens in a new tab with noopener,noreferrer semantics by default.

The downstream app's access token has the downstream app audience, while Auth Mini account management requires Auth Mini's self audience. The user may therefore need to sign in again in that Auth Mini tab; the component does not transfer a downstream token across that boundary.

Passkey registration popup

openPasskeyRegistrationPage opens Auth Mini's dedicated passkey-registration page in a named popup. The Provider supplies its configured Auth Mini base URL, so call it from a user interaction below that Provider.

import { useAuthMini } from 'auth-mini-react-components';

function RegisterPasskeyButton() {
  const { openPasskeyRegistrationPage } = useAuthMini();

  return (
    <button onClick={openPasskeyRegistrationPage}>Register passkey</button>
  );
}

The function returns the popup window, or null when the browser blocks it. It does not transfer the downstream app's token; the popup uses its own Auth Mini session.

AuthMiniProvider props

| Prop | Description | | --------------------- | ---------------------------------------------------------------------------------------------------------------- | | authMiniBaseUrl | Required Auth Mini issuer/server base URL. | | callbackUrl | Callback URL string or lazy callback; defaults to the current browser URL. | | audience | Explicit audience for loopback callbacks only. | | autoRedirectToLogin | Required. true redirects anonymous sessions after callback processing; false leaves them in the application. | | onAuthStateChange | Receives every Browser SDK session snapshot. | | onAuthError | Receives callback, SDK, or redirect-preparation errors. |

useAuthMini

useAuthMini() must be called below AuthMiniProvider. It returns the shared sdk, session, status, isReady, isAuthenticated, error, signIn, signOut, and openPasskeyRegistrationPage values. The Browser SDK remains the authority for session tokens; the hook does not create a second token store.

AuthMiniButton props

AuthMiniButton must be rendered below AuthMiniProvider and inherits the Provider configuration.

| Prop | Description | | ------------------------------ | -------------------------------------------------------------------------------- | | lang | Required language string. zh and zh-* use Chinese; other values use English. | | securitySettingsUrl | Overrides the default Auth Mini /web/#/ target. | | securitySettingsTarget | _blank by default; _self is supported. | | variant, size, className | Match familiar shadcn button customization when signed out. | | labels | Overrides individual visible control text, including addPasskey. |