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

@realchemistry/auth-guard-react

v0.1.1

Published

React companion to @realchemistry/auth-guard. Provides <AuthProvider>, useAuth(), and <UserMenu/> for reading the signed-in user from the auth-guard chassis (/auth/me) and rendering a standard sign-in pill. The chassis does the authentication; this packag

Downloads

284

Readme

@realchemistry/auth-guard-react

React companion to @realchemistry/auth-guard. The chassis does the authentication; this package only reads the result and renders a standard sign-in pill.

When to use

Use this package if and only if your RC app is React-based and you want the standard user-pill UI without re-deriving fetch('/auth/me'), loading states, and sign-out plumbing per app. Non-React apps (Streamlit, Flask, Express templates) should keep reading the three x-rc-user-* headers directly server-side.

This package does not authenticate anyone. The auth-guard chassis still does all of that. This package only reads /auth/me and renders the result.

Install

pnpm add @realchemistry/auth-guard-react

Requires that @realchemistry/auth-guard is already wired into the project (the auth-guard serve chassis is what serves /auth/me).

Use

import { AuthProvider, UserMenu, useAuth } from "@realchemistry/auth-guard-react";

export function App() {
  return (
    <AuthProvider>
      <header>
        <h1>My RC App</h1>
        <UserMenu />
      </header>
      <Main />
    </AuthProvider>
  );
}

function Main() {
  const { email, loading } = useAuth();
  if (loading) return <p>Loading…</p>;
  return <p>Welcome, {email}</p>;
}

API

<AuthProvider>

Holds the auth context. Fetches /auth/me once on mount; exposes the result via context.

Props:

| Prop | Type | Default | Notes | |---|---|---|---| | meUrl | string | "/auth/me" | Override if the chassis serves /auth/me at a non-default path. | | initial | { email, sub, emailVerified } | — | Skip the first fetch if identity is pre-injected (SSR). | | children | ReactNode | — | Your app. |

useAuth()

const { email, sub, emailVerified, loading, error, refetch } = useAuth();

Throws if called outside <AuthProvider>.

<UserMenu/>

Renders a pill with the user's email and a "Sign out" link. While loading, renders a neutral skeleton. If unauthenticated, renders a "Sign in" link.

Props (all optional):

| Prop | Type | Default | |---|---|---| | loginUrl | string | "/auth/login" | | logoutUrl | string | "/auth/logout" | | next | string | current pathname | | renderLabel | (state) => string | ({email}) => email | | className | string | — | | style | CSSProperties | — | | loadingFallback | ReactNode | built-in skeleton |

Style via CSS variables on any parent:

:root {
  --rc-auth-bg: #f4f4f5;
  --rc-auth-fg: #18181b;
  --rc-auth-border: #e4e4e7;
  --rc-auth-link: #2563eb;
  --rc-auth-skeleton-bg: #e4e4e7;
  --rc-auth-fontsize: 0.875rem;
}

For richer customization, skip <UserMenu/> and build your own with useAuth().

What this package does not do

  • It does not authenticate. The chassis does.
  • It does not redirect. It renders a sign-in link; the chassis handles the OAuth round-trip when the link is clicked.
  • It does not poll. It fetches /auth/me once on mount. Call refetch() if you need to re-check (e.g. after a sign-out the chassis just handled).
  • It does not gate route access (no <RequireAuth>). The chassis bounces unauthenticated requests server-side before React renders, so a client-side route gate would be dead code in most cases.