get401
v1.0.14
Published
Easy authentication SDK for React, Vue, Next.js, Express, and React Native applications - Get401 Auth
Maintainers
Readme
get401
Authentication SDK with email/password login, OTP, account recovery, and ready-made React UI components.
Installation
npm install get401Quick Start (React)
import { Get401Provider, useAuth } from 'get401';
// 1. Wrap your app
function App() {
return (
<Get401Provider appId="your-app-id">
<YourApp />
</Get401Provider>
);
}
// 2. Use the hook
function LoginPage() {
const { login, challengeOTP, nextStep, error, isLoading } = useAuth();
// login(email, password) -> if nextStep === 'otp' -> challengeOTP(code)
}Quick Start (Vanilla JS)
import { Get401Client } from 'get401';
const client = new Get401Client('your-app-id');
await client.login('[email protected]', 'password123');
// If MFA enabled: await client.challengeOTP('123456');Features
- Login — email + password, with optional OTP (MFA)
- Registration — email verification + OTP setup with QR code
- Recovery — password recovery (verify via OTP) and OTP recovery (verify via password)
- Ready-made UI —
AuthModal,LoginForm,RegisterForm,ProtectedRoute - TypeScript — full type definitions included
Authentication Flows
Login
login(email, password) -> challengeOTP(code) -> AuthenticatedRegistration
register(email, password) -> challengeEmailSetup(code) -> getQRCode() -> verifyOTPSetup(code) -> AuthenticatedPassword Recovery
recoveryInit(email, 'password') -> recoveryVerifyEmail(code) -> recoveryVerifyFactor('otp', code) -> setupPassword(pwd) -> AuthenticatedOTP Recovery
recoveryInit(email, 'otp') -> recoveryVerifyEmail(code) -> recoveryVerifyFactor('password', pwd) -> getQRCode() -> verifyOTPSetup(code) -> AuthenticatedNote:
recoveryVerifyFactoruses different payloads — OTP sends{ type, code }, password sends{ type, cred }. The SDK handles this automatically.
Documentation
- React Guide —
useAuthhook, components, full examples - Core API Guide —
Get401Clientfor vanilla JS / Node.js
License
MIT
