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

@nexefy/auth-react

v1.4.0

Published

React hooks for Nexefy Auth SDK

Downloads

272

Readme

@nexefy/auth-react

React hooks for Nexefy Auth SDK - OAuth 2.1 authentication made easy.

Installation

npm install @nexefy/auth-react @nexefy/auth-client
# or
pnpm add @nexefy/auth-react @nexefy/auth-client

Quick Start

import { createNexefyClient } from '@nexefy/auth-client'
import { NexefyProvider, useNexefyAuth } from '@nexefy/auth-react'

// Create client
const nexefy = createNexefyClient({
  authUrl: 'https://auth.nexefy.com',
  clientId: 'your-client-id',
  organisationSlug: 'your-org',
  scopes: ['openid', 'profile', 'email', 'offline_access']
})

// Wrap your app
function App() {
  return (
    <NexefyProvider client={nexefy}>
      <YourApp />
    </NexefyProvider>
  )
}

// Use in components
function YourApp() {
  const { user, isAuthenticated, isLoading, signIn, signOut } = useNexefyAuth()

  // Do NOT route to login while loading — a silent refresh may be in flight.
  if (isLoading) {
    return <div>Loading…</div>
  }

  if (!isAuthenticated) {
    return <button onClick={() => signIn()}>Sign In</button>
  }

  return (
    <div>
      <h1>Welcome {user?.name}</h1>
      <button onClick={() => signOut()}>Sign Out</button>
    </div>
  )
}

Hooks

useNexefyAuth()

Main authentication hook.

const {
  // state
  user,
  session,
  isLoading,
  isAuthenticated,
  sessionStatus,   // 'loading' | 'authenticated' | 'unauthenticated' | 'recoverable'
  authError,       // last terminal refresh failure (e.g. invalid_grant), or null
  // methods
  signIn,          // (options?) => Promise<void>  — begins OAuth redirect
  handleCallback,  // (url?) => Promise<boolean>
  signOut,         // (options?) => Promise<void>  — accepts { federated }
  refreshToken,    // () => Promise<boolean>
  authenticatedFetch,
  getAccessToken,
  getIdToken,
  client
} = useNexefyAuth()

isAuthenticated stays stable across access-token expiry: it remains true while a recoverable silent refresh is in flight, so the UI does not flash the login screen every hour. Gate route guards on isLoading / sessionStatus rather than redirecting on !isAuthenticated alone.

Switching users

const { signOut, signIn } = useNexefyAuth()

// Force the IDP login screen so a different user can sign in
await signOut()
await signIn({ prompt: 'login' })

// Or end the IDP SSO session entirely (federated logout)
await signOut({ federated: true })

Terminal refresh failures

The provider listens for tokenRefreshFailed. A terminal invalid_grant clears the session and surfaces via authError; transient (network/5xx) failures are ignored so the user is not logged out unnecessarily.

useNexefyUser()

User-specific data hook.

const {
  user,
  isLoading,
  organisationSlug,
  teams,
  role
} = useNexefyUser()

Compatibility

Requires @nexefy/auth-client@^1.4.0 (for hydrateSession() and federated sign-out). The provider falls back gracefully on older clients but sessionStatus / federated logout require 1.4.0+.

License

MIT