Production-ready authentication UI components for React applications
Complete authentication solution with built-in pages, RBAC support, and session management. Drop-in components that work with any backend API.
- π Pre-built Auth Pages - Login, Register, Password Reset, Profile
- π‘οΈ RBAC Support - Role-based access control with permissions
- π Session Management - Automatic token refresh and expiration handling
- π¨ Customizable - Headless components, bring your own styles
- βΏ Accessible - ARIA-compliant, keyboard navigation
- π i18n Ready - Multi-language support via
@ciscode/ui-translate-core - π± Responsive - Mobile-first design
- π TypeScript - Full type safety
npm install @ciscode/ui-authentication-kit
# or
yarn add @ciscode/ui-authentication-kit
# or
pnpm add @ciscode/ui-authentication-kitnpm install react react-dom react-router-dom axios jwt-decode react-cookie lucide-react @ciscode/ui-translate-coreimport { AuthProvider } from '@ciscode/ui-authentication-kit';
import { BrowserRouter } from 'react-router-dom';
function App() {
return (
<BrowserRouter>
<AuthProvider
config={{
apiUrl: 'https://api.example.com',
loginPath: '/auth/login',
registerPath: '/auth/register',
profilePath: '/auth/profile',
logoutPath: '/auth/logout',
redirectAfterLogin: '/dashboard',
redirectAfterLogout: '/',
}}
>
{/* Your app routes */}
</AuthProvider>
</BrowserRouter>
);
}import { useAuthState } from '@ciscode/ui-authentication-kit';
function Dashboard() {
const { user, isAuthenticated, logout } = useAuthState();
if (!isAuthenticated) {
return <div>Please log in</div>;
}
return (
<div>
<h1>Welcome, {user?.name}!</h1>
<button onClick={logout}>Logout</button>
</div>
);
}import { RequirePermissions } from '@ciscode/ui-authentication-kit';
function AdminPanel() {
return (
<RequirePermissions
fallbackpermessions={['admin.view', 'admin.edit']}
fallbackRoles={['super-admin']}
redirectTo="/unauthorized"
>
<div>Admin Content</div>
</RequirePermissions>
);
}- API Reference - Complete API documentation
- Examples - Integration examples
- Styling Guide - Customization guide
- Accessibility - A11y patterns
- Migration Guide - Upgrade guides
- Architecture - Project structure
- Release Guide - Release workflow
- Tests are centralized under the
tests/folder. - Vitest is configured with jsdom and a global setup in tests/setup.ts.
- Run tests:
npm test - Run coverage:
npm run test:cov
Folder layout:
tests/
components/
context/
hooks/
utils/
setup.ts
| Component | Description |
|---|---|
AuthProvider |
Root provider for authentication state and routing |
ProfilePage |
User profile management UI |
RequirePermissions |
Permission-based route guard |
RbacProvider |
Role-based access control context |
| Hook | Description |
|---|---|
useAuthState() |
Access auth state (user, isAuthenticated, login, logout) |
useHasRole(role) |
Check if user has a specific role |
useHasModule(module) |
Check if user has access to a module |
useCan(permission) |
Check if user has a permission |
useGrant() |
Access RBAC grant management |
import { RbacProvider, useHasRole, useCan } from '@ciscode/ui-authentication-kit';
function App() {
return (
<RbacProvider>
<Dashboard />
</RbacProvider>
);
}
function Dashboard() {
const isAdmin = useHasRole('admin');
const canEditUsers = useCan('users.edit');
return (
<div>
{isAdmin && <AdminPanel />}
{canEditUsers && <EditButton />}
</div>
);
}The kit integrates with @ciscode/ui-translate-core for multi-language support:
import { TranslateProvider } from '@ciscode/ui-translate-core';
<TranslateProvider locale="en" translations={translations}>
<AuthProvider config={config}>
<App />
</AuthProvider>
</TranslateProvider>;# Install dependencies
npm install
# Build the library
npm run build
# Run tests
npm test
# Run tests with coverage
npm run test:cov
# Type check
npm run typecheck
# Lint
npm run lint
# Format code
npm run format:writeWe welcome contributions! Please see CONTRIBUTING.md for details.
- Fork the repository
- Create a feature branch from
develop - Make your changes with tests
- Submit a PR to
develop
ISC Β© CISCODE
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
Built with modern React patterns and best practices. Designed for enterprise applications.