@explita/u-auth v0.2.11
u-auth - Simplified Authentication for React
A lightweight authentication library for React applications. Provides utilities to handle common authentication tasks like managing authentication tokens, verifying sessions, handling cookies, and supporting both OTP and token-based authentication.
✨ Features
- 📱 OTP-based login support
- 🔐 JWT token session handling
- ⚛️ React hooks for seamless UX
- 💼 Works with Next.js API and server functions
- 💅 Minimal styles with Tailwind support
🚀 Installation
npm install @explita/u-author
yarn add @explita/u-author
pnpm add @explita/u-authMake sure you also have these as peer dependencies:
npm install react react-domAdd the CSS
import '@explita/u-auth/styles.css';📜 Session Management
The u-auth library handles session management by automatically storing and retrieving authentication tokens using HTTP-only cookies for better security.
Authentication tokens are stored in cookies, with the HttpOnly flag to prevent JavaScript access.
The useAuth hook allows easy access to session data in any component.
🔐 Authentication Methods
Token-Based Authentication
Use JWT tokens for stateless authentication. The library provides helpers to manage tokens and sessions using cookies.
OTP-Based Authentication
You can implement OTP-based authentication by using the OTPProvider, OTPInput and useOTP hook. This is ideal for scenarios where you want to verify users via an OTP sent to their email or phone.
📄 License
MIT — Made with ❤️ by Explita