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 🙏

© 2025 – Pkg Stats / Ryan Hefner

hasura-auth-js

v3.0.0

Published

Hasura Auth client library for JavaScript/TypeScript. A drop-in replacement for the deprecated @nhost/hasura-auth-js package. Supports Email/Password, OAuth, WebAuthn, Passwordless, MFA, and more.

Readme

hasura-auth-js

npm version DOWNLOADS License: MIT

Optimized Hasura Auth client library with latest packages and improved performance. A drop-in replacement for the deprecated @nhost/hasura-auth-js package.

Note: This package is based on the original @nhost/hasura-auth-js package by Nhost. The original package has been deprecated in favor of @nhost/nhost-js@^4.0.0. This fork provides an updated version with the latest dependencies and optimizations.

Versioning

This package uses version 3.0.0 to indicate it's the next major version after the deprecated @nhost/hasura-auth-js package (which ended at v2.12.0). The major version bump reflects:

  • Major dependency updates: WebAuthn v13.2.2, Vite 7, TypeScript 5.9
  • API changes: Updated WebAuthn function signatures
  • Removed deprecated packages: No longer depends on deprecated @simplewebauthn/types
  • Modern build tooling: Latest stable versions of all dependencies

This follows semantic versioning principles, where version 3.0.0 signals significant updates and improvements over the 2.x series.

Features

  • 🔐 Multiple Authentication Methods: Email/Password, Passwordless, OAuth, WebAuthn, Anonymous, MFA
  • 🔄 Automatic Token Refresh: Built-in token refresh with Bearer token support
  • 🔒 MFA Support: Multi-Factor Authentication with TOTP
  • 🎫 Personal Access Tokens: Create and manage PATs
  • 📱 Cross-tab Synchronization: Automatic session sync across browser tabs
  • 🎯 TypeScript Support: Full TypeScript definitions included
  • Optimized: Latest stable dependencies and modern build tools
  • 📦 Dual Format: Supports both ESM and CommonJS
  • 🗺️ Source Maps: Full source maps for debugging

For a complete list of features and methods, see FEATURES.md.

Installation

npm install hasura-auth-js
# or
pnpm add hasura-auth-js
# or
yarn add hasura-auth-js

Quick Start

import { HasuraAuthClient } from 'hasura-auth-js'

// Initialize the client
const auth = new HasuraAuthClient({
  url: 'https://your-hasura-auth-endpoint.com'
})

// Sign up
const { session, error } = await auth.signUp({
  email: '[email protected]',
  password: 'secure-password'
})

if (error) {
  console.error('Sign up error:', error)
} else {
  console.log('User signed up:', session?.user)
}

// Sign in
const { session: signInSession, error: signInError } = await auth.signIn({
  email: '[email protected]',
  password: 'secure-password'
})

// Check authentication status
const isAuthenticated = auth.isAuthenticated()
const currentSession = auth.getSession()

// Sign out
await auth.signOut()

More Examples

// Passwordless email (magic link)
await auth.signIn({ email: '[email protected]' })

// OAuth provider
await auth.signIn({ provider: 'google' })

// Anonymous sign in
await auth.signIn()

// Get access token
const token = auth.getAccessToken()

// Listen to auth state changes
auth.onAuthStateChanged((event, session) => {
  console.log('Auth state changed:', event, session)
})

For more examples and API reference, see FEATURES.md.

Migration from @nhost/hasura-auth-js

This package is a drop-in replacement for the deprecated @nhost/hasura-auth-js:

  1. Uninstall the old package:

    npm uninstall @nhost/hasura-auth-js
  2. Install the new package:

    npm install hasura-auth-js
  3. Update your imports:

    // Before
    import { HasuraAuthClient } from '@nhost/hasura-auth-js'
       
    // After
    import { HasuraAuthClient } from 'hasura-auth-js'

That's it! The API is identical, so no other code changes are needed.

Documentation

Requirements

  • Node.js: >= 18.0.0
  • Browsers: Modern browsers with ES2022 support
  • Hasura Auth: Compatible with Hasura Auth v0.38.0+

Credits

This package is based on the original work by Nhost:

License

MIT