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

@auditauth/react

v0.2.0-beta.8

Published

AuditAuth React SDK

Readme

@auditauth/react

@auditauth/react is the AuditAuth SDK integration for React applications. It provides a provider, a hook, and a route guard to handle redirect callbacks, session state, login and logout actions, and authenticated HTTP calls.

Install

Install the package in your React application.

npm install @auditauth/react

TypeScript import compatibility

@auditauth/react ships dual module output (ESM + CJS) with declaration files. You can import it in TypeScript projects with standard syntax:

import { AuditAuthProvider } from '@auditauth/react'

You do not need to append .js in consumer imports.

@auditauth/react has peer dependencies on react and react-dom version 18 or higher.

Wrap your app with the provider

Create one top-level AuditAuthProvider and pass your AuditAuth config.

import { AuditAuthProvider } from '@auditauth/react'

export function AppRoot() {
  return (
    <AuditAuthProvider
      config={{
        apiKey: import.meta.env.VITE_AUDITAUTH_API_KEY,
        appId: import.meta.env.VITE_AUDITAUTH_APP_ID,
        baseUrl: 'http://localhost:5173',
        redirectUrl: 'http://localhost:5173/private',
      }}
    >
      <App />
    </AuditAuthProvider>
  )
}

The provider runs handleRedirect() on startup and exposes the current user and session actions through useAuditAuth().

Protect private UI with RequireAuth

Wrap private content with RequireAuth to trigger login when the user is not authenticated.

import { RequireAuth } from '@auditauth/react'

export function PrivatePage() {
  return (
    <RequireAuth>
      <h1>Private area</h1>
    </RequireAuth>
  )
}

RequireAuth renders children only after the SDK is ready and the user has a valid session.

Use auth state and actions in components

Use useAuditAuth() inside components that are children of AuditAuthProvider.

import { useAuditAuth } from '@auditauth/react'

export function AccountMenu() {
  const { user, ready, login, logout, goToPortal } = useAuditAuth()

  if (!ready) return null

  if (!user) {
    return <button onClick={() => login()}>Login</button>
  }

  return (
    <div>
      <span>{user.email}</span>
      <button onClick={() => goToPortal()}>Portal</button>
      <button onClick={() => logout()}>Logout</button>
    </div>
  )
}

Make authenticated API calls

Use fetch from useAuditAuth() instead of window.fetch() for authenticated requests. The SDK attaches the session token and handles refresh behavior when needed.

import { useAuditAuth } from '@auditauth/react'

export function ProfileButton() {
  const { fetch } = useAuditAuth()

  const loadProfile = async () => {
    const response = await fetch('https://api.example.com/private/profile')
    const data = await response.json()
    console.log(data)
  }

  return <button onClick={loadProfile}>Load profile</button>
}

Track navigation metrics

If you use a client router such as React Router, call trackNavigationPath() when the path changes.

import { useEffect } from 'react'
import { useLocation } from 'react-router-dom'
import { useAuditAuth } from '@auditauth/react'

export function NavigationTracker() {
  const { pathname } = useLocation()
  const { trackNavigationPath } = useAuditAuth()

  useEffect(() => {
    trackNavigationPath(pathname)
  }, [pathname, trackNavigationPath])

  return null
}

API reference

useAuditAuth() returns:

  • ready: boolean
  • user: SessionUser | null
  • fetch(input, init?): Promise<Response>
  • login(): Promise<void>
  • logout(): Promise<void>
  • goToPortal(): Promise<void>
  • isAuthenticated(): boolean
  • trackNavigationPath(path: string): void

Exports from @auditauth/react:

  • AuditAuthProvider
  • useAuditAuth
  • RequireAuth

Compatibility

This package requires:

  • Node.js >=18.18.0 for tooling and build environments
  • React >=18
  • React DOM >=18

Resources

  • Repository: https://github.com/nimibyte/auditauth-sdk
  • Documentation: https://docs.auditauth.com

Example

See examples/react for a complete Vite + React Router integration.

License

MIT