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

@newco-ai-platform/sdk-react

v0.2.0

Published

NewCo Suite React auth surface — AuthProvider + AuthGuard + useUser + useSession, now with a pluggable Clerk adapter. Zero direct provider SDK imports outside the adapter modules.

Downloads

358

Readme

@newco-ai-platform/sdk-react

React auth surface for the NewCo Suite — <AuthGuard>, useUser(), useSession(), plus a pluggable AuthAdapter shape. Mirrors the Python newco_sdk.auth surface so a developer touching both sides learns one API.

Zero direct Clerk / Authentik / OIDC imports. Concrete adapters ship in subsequent stories alongside their Python counterparts (NEW-36 epic). Web apps depend on this package; the provider plug-in lives in the host app via the <AuthProvider adapter={…}> boundary.

Install

npm install @newco-ai-platform/sdk-react react

React 18 or 19 is a peer dependency.

Usage

import {
  AuthProvider,
  AuthGuard,
  useUser,
  useSession,
  type AuthAdapter,
} from '@newco-ai-platform/sdk-react';
import { useState } from 'react';

function App() {
  const [auth, setAuth] = useState({ user: null, session: null });

  const adapter: AuthAdapter = {
    ...auth,
    signOut: () => setAuth({ user: null, session: null }),
  };

  return (
    <AuthProvider adapter={adapter}>
      <AuthGuard onUnauthenticated={() => router.replace('/sign-in')}>
        <Dashboard />
      </AuthGuard>
    </AuthProvider>
  );
}

function Dashboard() {
  const user = useUser();
  const session = useSession();
  return <p>Hello {user?.name} (org {session?.org_id})</p>;
}

API

<AuthProvider adapter={…}>

Wraps the tree with the auth context. Reads user, session, signOut off the adapter; context value updates when any of the three references change.

<AuthGuard>

Gates children on useSession() !== null. Children NEVER render when the session is null — the fallback (or built-in sign-in prompt) renders instead.

Props:

| Prop | Type | Default | Notes | |---------------------|---------------------|--------------------------|--------------------------------------------------------| | children | ReactNode | required | Rendered only when authenticated. | | fallback | ReactNode | minimal sign-in panel | Rendered when session === null. | | onUnauthenticated | () => void | — | Fired in useEffect when session === null. Wire to your router. |

useUser(): User | null

Current user, or null when unauthenticated. Throws if called outside <AuthProvider>.

useSession(): Session | null

Current session, or null when unauthenticated. Throws if called outside <AuthProvider>.

useAuth(): { user, session, signOut }

Escape hatch — most callers should use the narrower useUser / useSession. Use this when you also need signOut.

AuthAdapter

interface AuthAdapter {
  user: User | null;
  session: Session | null;
  signOut: () => void;
}

Concrete adapters (Clerk, Authentik, OIDC) ship as separate packages in subsequent stories. The simplest local pattern is to hold auth state in useState and recreate the adapter on each render (see the example above).

Types

User, Session, and IdentityProvider mirror the canonical zod schemas in @newco-ai-platform/types/auth. They're declared locally here (TS-only, no zod runtime) so apps don't pull a validation library into the bundle just to read User.email. Shape MUST match the canonical schema — contracts-owner PR review catches divergence.

Scripts

| Script | What it does | |---------------------|------------------------------------| | npm run typecheck | tsc --noEmit | | npm test | vitest run (jsdom environment) | | npm run build | tsup → ESM + CJS + d.ts in dist/ |

License

UNLICENSED — internal use.