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

flexauth-ui

v1.0.2

Published

Reusable React + Material UI authentication components

Readme

flexauth-ui

A reusable React authentication UI library with Material UI components. Provides drop-in login, registration, OAuth, and BankID components that connect to the FlexAuth backend.

Installation

npm install flexauth-ui @mui/material @emotion/react @emotion/styled @mui/icons-material

Prerequisites

You need the FlexAuth backend running. Clone and deploy it:

git clone https://github.com/toihid/FlexAuth.git
cd FlexAuth/packages/auth-backend
cp .env.example .env
# Edit .env with your MongoDB URI and secrets
pnpm install
pnpm dev

Backend will run at http://localhost:4000.

Quick Start

import { AuthLogin, AuthProvider, AuthConfigProvider } from 'flexauth-ui';

const config = {
  apiBaseUrl: 'http://localhost:4000', // Your FlexAuth backend URL
};

function LoginPage() {
  return (
    <AuthConfigProvider config={config}>
      <AuthProvider config={config}>
        <AuthLogin />
      </AuthProvider>
    </AuthConfigProvider>
  );
}

That's it — full login page with email/password, OAuth buttons, and BankID support.

Components

<AuthLogin />

Complete login form with dynamic provider rendering based on backend config.

<AuthLogin
  onRegisterClick={() => router.push('/register')}
  onForgotPasswordClick={() => console.log('forgot password')}
/>

<AuthRegister />

Registration form with dynamic fields based on enabled identifiers.

<AuthRegister
  onLoginClick={() => router.push('/login')}
/>

<MfaVerification />

Two-factor authentication code input.

<MfaVerification
  challengeId="..."
  method="totp"
  onVerify={async (code) => { /* verify code */ }}
  onCancel={() => { /* go back */ }}
/>

Context Providers

<AuthConfigProvider>

Fetches enabled providers and branding from the backend. Wrap your auth pages with this.

<AuthConfigProvider config={{ apiBaseUrl: 'https://your-backend.com' }}>
  {children}
</AuthConfigProvider>

<AuthProvider>

Manages authentication state (user, tokens, login/logout actions).

<AuthProvider config={{ apiBaseUrl: 'https://your-backend.com' }}>
  {children}
</AuthProvider>

Hooks

useAuth()

Access authentication state and actions anywhere in your app.

import { useAuth } from 'flexauth-ui';

function MyComponent() {
  const { user, isAuthenticated, isLoading, login, logout } = useAuth();

  if (isLoading) return <p>Loading...</p>;
  if (!isAuthenticated) return <p>Not logged in</p>;

  return (
    <div>
      <p>Welcome, {user.displayName}</p>
      <button onClick={logout}>Logout</button>
    </div>
  );
}

useAuthConfig()

Access provider config and branding.

import { useAuthConfig } from 'flexauth-ui';

function MyComponent() {
  const { providers, branding } = useAuthConfig();
  // providers = [{type: 'local', ...}, {type: 'google', ...}]
  // branding = {appName: 'My App', primaryColor: '#1976d2'}
}

Configuration

const config = {
  apiBaseUrl: 'http://localhost:4000',  // Required: FlexAuth backend URL
  onSuccess: (session) => {             // Optional: called after successful login
    console.log('Logged in:', session.user.displayName);
    window.location.href = '/dashboard';
  },
  onError: (error) => {                 // Optional: called on auth error
    console.error(error.message);
  },
  showRegister: true,                   // Optional: show "Sign up" link
  showForgotPassword: true,             // Optional: show "Forgot password" link
  branding: {                           // Optional: override branding from backend
    appName: 'My App',
    primaryColor: '#1976d2',
  },
};

Features

  • Dynamic provider rendering — Only shows login methods enabled by admin
  • Email / Username / Mobile login — Toggle identifier types via admin panel
  • Google OAuth — One-click Google login (requires backend credentials)
  • BankID — Swedish BankID authentication (server-side)
  • MFA support — Two-factor authentication
  • Responsive design — Works on mobile and desktop
  • Admin-controlled — No code changes needed to enable/disable providers
  • Secure by default — All sensitive operations are server-side

Admin Panel

The FlexAuth backend includes an admin panel where you can:

  • Enable/disable authentication providers
  • Set password requirements
  • Configure account lockout rules
  • Customize branding (app name, colors, logo)

Peer Dependencies

  • react >= 18
  • @mui/material >= 5
  • @emotion/react >= 11
  • @emotion/styled >= 11

License

MIT

Links

  • GitHub: https://github.com/toihid/FlexAuth
  • npm: https://www.npmjs.com/package/flexauth-ui