Registry / web-framework / xadmin-auth

xadmin-auth

JSON →
library3.3.4jsnpmunverified

Xadmin Auth is the authentication module for the Xadmin ecosystem (v3.3.4), providing user login, logout, permission checks, and session management for React applications. It integrates tightly with xadmin-model and xadmin-form v3, requires react-router-dom v6 for routing, and lodash for utilities. Designed for admin panels, it offers higher-level auth components and hooks compared to raw auth libraries. Release cadence is irregular but semver-compliant. Key differentiator: seamless with Xadmin UI framework; standalone use is not recommended without adjacent xadmin packages.

npm install xadmin-auth
INSTALL
IMPORT
SIG · XADMIN-AUTH
X
xadmin-auth
web-frameworkjavascriptv3.3.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AuthProvider
import { AuthProvider } from 'xadmin-auth'
const AuthProvider = require('xadmin-auth')
ESM-only package since v3; CommonJS require will fail.
useAuth
import { useAuth } from 'xadmin-auth'
import useAuth from 'xadmin-auth'
Named export, not default export.
withAuth
import { withAuth } from 'xadmin-auth'
import { withAuth } from 'xadmin-auth/withAuth'
Import directly from package root; subpaths may break in future versions.

Shows setup of AuthProvider and useAuth hook with a basic login form.

import React from 'react'; import { AuthProvider, useAuth } from 'xadmin-auth'; import { Xadmin } from 'xadmin'; function LoginPage() { const { login } = useAuth(); const handleSubmit = async (e) => { e.preventDefault(); const form = new FormData(e.target); try { await login(form.get('username'), form.get('password')); alert('Logged in!'); } catch (err) { alert('Login failed: ' + err.message); } }; return ( <form onSubmit={handleSubmit}> <input name="username" placeholder="Username" /> <input name="password" type="password" placeholder="Password" /> <button type="submit">Log In</button> </form> ); } function App() { return ( <Xadmin> <AuthProvider> <LoginPage /> </AuthProvider> </Xadmin> ); } export default App;
Debug
Known issues
breakingv3 drops CommonJS support; only ES modules are provided.
fix
Ensure your project uses ESM (type: module in package.json) and uses import statements.
affects: >=3.0.0
breakingv3 restructured exports; 'authenticated' HOC replaced by 'withAuth' and 'AuthProvider' is now required.
fix
Wrap app in <AuthProvider> and replace 'authenticated' with 'withAuth(Component)'.
affects: >=3.0.0 <4.0.0
deprecatedThe 'signOut' method in useAuth is deprecated in favor of 'logout'.
fix
Replace signOut() calls with logout().
affects: >=3.2.0 <4.0.0
gotchaAuthProvider and useAuth must be used within an Xadmin component tree.
fix
Wrap your app with <Xadmin> before <AuthProvider>.
affects: >=3.0.0
gotchaThe 'login' method expects FormData-like structure; passing plain objects may fail.
fix
Use FormData or ensure object has 'username' and 'password' fields as per API expectations.
affects: >=3.0.0
Errors
Common errors & fixes
Module not found: Can't resolve 'xadmin-auth'
Package not installed or not in node_modules.
fix
Run 'npm install xadmin-auth' or 'yarn add xadmin-auth'.
TypeError: Cannot destructure property 'login' of '(0 , ...)' as it is undefined.
useAuth hook called outside of AuthProvider.
fix
Ensure component is inside <AuthProvider>.
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function but got: object.
Importing a default export when only named exports exist (e.g., import AuthProvider from 'xadmin-auth').
fix
Use named import: import { AuthProvider } from 'xadmin-auth'.
Upgrade
Version history
3.3.4latest on npm
Audit
Dependencies
reactrequiredJSX and component lifecycle needed for auth components
lodashrequiredUtility functions for object manipulation and deep cloning
react-router-domrequiredRouting for protected routes and navigation after auth actions
xadminrequiredCore Xadmin framework providing base abstractions
xadmin-formrequiredForm handling for login and registration forms
xadmin-i18nrequiredInternationalization support for auth UI messages
xadmin-modelrequiredData models for user and permission entities
Agent activity
51 hits · last 30 days
node
40
Perplexity
1
OpenAI (training)
1
Resources