@nauth-toolkit/client
v0.2.5
Published
Frontend authentication SDK for nauth-toolkit — framework-agnostic TypeScript
Downloads
516
Maintainers
Readme
@nauth-toolkit/client
Framework-agnostic frontend SDK for nauth-toolkit.
Handles authentication flows from the browser — signup, login, token refresh, MFA, social OAuth, session management. Works with React, Vue, Svelte, or any TypeScript/JavaScript frontend. Ships as both CJS and ESM.
Part of nauth-toolkit. Works with any nauth-toolkit backend.
Install
npm install @nauth-toolkit/clientQuick start
import { NAuthClient } from '@nauth-toolkit/client';
const auth = new NAuthClient({
baseUrl: 'https://api.example.com/auth',
});
// Sign up
await auth.signup({ email: '[email protected]', password: 'securePass1!' });
// Log in
const result = await auth.login({ email: '[email protected]', password: 'securePass1!' });
// Get current user
const user = auth.getUser();
// Listen for auth state changes
auth.on('authStateChanged', (user) => {
console.log('Auth state:', user);
});What's included
- NAuthClient — typed API client for all nauth-toolkit endpoints
- Token management — automatic silent refresh, pluggable storage (browser or in-memory)
- MFA flows — TOTP enrollment, SMS/email verification, passkey registration and authentication
- Social OAuth — redirect and popup flows for Google, Apple, Facebook
- Session management — list sessions, revoke sessions, device info
- Challenge router — automatic multi-step flow handling (MFA challenges, email verification)
- Admin operations — user management for admin-scoped tokens
Angular
For Angular apps, use @nauth-toolkit/client-angular which wraps this SDK with Angular services, guards, and HTTP interceptors.
Free to use. See license.
