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

@inai-dev/react

v0.7.0

Published

React components, hooks, and providers for InAI Auth

Readme

@inai-dev/react

React hooks and components for InAI Auth. Provides authentication context, hooks for accessing user/session data, and pre-built UI components.

Installation

npm install @inai-dev/react

Provider

Wrap your app with InAIAuthProvider. It reads session data from the auth_session cookie (set by the server-side auth routes) — no props required.

import { InAIAuthProvider } from "@inai-dev/react";

function App({ children }) {
  return (
    <InAIAuthProvider>{children}</InAIAuthProvider>
  );
}

Hooks

useAuth()

const { isLoaded, isSignedIn, userId, roles, permissions, has, signOut, refreshSession } = useAuth();

has({ role: "admin" });       // check role
has({ permission: "read" });  // check permission
await signOut();              // logout and redirect
await refreshSession();       // refresh tokens

useUser()

const { isLoaded, isSignedIn, user } = useUser();
// user: UserResource | null (id, email, firstName, lastName, avatarUrl, roles, ...)

useSession()

const { isLoaded, isSignedIn, userId, tenantId, orgId, orgRole, roles, permissions } = useSession();

useOrganization()

const { isLoaded, orgId, orgRole } = useOrganization();

useSignIn()

const { signIn, isLoading, error, status, reset } = useSignIn();

await signIn.create({ identifier: "[email protected]", password: "..." });
// status: "idle" | "loading" | "needs_mfa" | "complete" | "error"

// MFA flow
await signIn.attemptMFA({ code: "123456" });

useSignUp()

const { signUp, isLoading, error, status, reset } = useSignUp();

await signUp.create({
  email: "[email protected]",
  password: "...",
  firstName: "Jane",
  lastName: "Doe",
});
// status: "idle" | "loading" | "needs_email_verification" | "complete" | "error"

Components

<Protect>

Renders children only if the user has the required role or permission.

<Protect role="admin" fallback={<p>Access denied</p>}>
  <AdminPanel />
</Protect>

<Protect permission="posts:write">
  <Editor />
</Protect>

<SignedIn> / <SignedOut>

Conditional rendering based on authentication state.

<SignedIn>
  <p>Welcome back!</p>
</SignedIn>
<SignedOut>
  <p>Please sign in.</p>
</SignedOut>

<PermissionGate>

Permission-based access control.

<PermissionGate permission="billing:manage" fallback={<p>No access</p>}>
  <BillingSettings />
</PermissionGate>

<UserButton>

User profile menu with avatar and dropdown.

<UserButton
  afterSignOutUrl="/"
  showName
  menuItems={[{ label: "Settings", onClick: () => router.push("/settings") }]}
  appearance={{ buttonSize: 36, buttonBg: "#1a1a2e" }}
/>

<SignIn>

Sign-in form with MFA support.

<SignIn
  redirectUrl="/dashboard"
  onSuccess={() => console.log("Signed in!")}
  onMFARequired={(mfaToken) => router.push("/mfa")}
/>

<OrganizationSwitcher>

Organization switching dropdown.

<OrganizationSwitcher />

Exports Reference

| Export | Kind | Description | |---|---|---| | InAIAuthProvider | Component | Auth context provider (no props) | | Protect | Component | Role/permission gate | | SignedIn | Component | Renders when signed in | | SignedOut | Component | Renders when signed out | | PermissionGate | Component | Permission-based gate | | UserButton | Component | User profile menu | | SignIn | Component | Sign-in form | | OrganizationSwitcher | Component | Org switcher | | useAuth | Hook | Auth state & actions | | useUser | Hook | User data | | useSession | Hook | Session info | | useOrganization | Hook | Organization data | | useSignIn | Hook | Sign-in flow | | useSignUp | Hook | Sign-up flow |

Questions & Support

Visit https://inai.dev for documentation, guides, and support.

License

MIT