Frontend SDK
Package: @nauth-toolkit/client
Type: Optional Client Library
Optional convenience layer for integrating nauth-toolkit into JavaScript/TypeScript applications. Provides token management, challenge flows, and typed API calls without prescribing UI.
info
The SDK is optional. Advanced users can integrate directly with backend APIs for custom workflows.
Installation
- npm
- Yarn
- pnpm
- Bun
npm install @nauth-toolkit/client
yarn add @nauth-toolkit/client
pnpm add @nauth-toolkit/client
bun add @nauth-toolkit/client
For Angular apps, also install the Angular adapter:
- npm
- Yarn
- pnpm
- Bun
npm install @nauth-toolkit/client-angular
yarn add @nauth-toolkit/client-angular
pnpm add @nauth-toolkit/client-angular
bun add @nauth-toolkit/client-angular
Choose Your Framework
| Framework | Guide | What You Get |
|---|---|---|
| Angular (Standalone) | Standalone Setup | Functional interceptor, guards, DI providers |
| Angular (NgModule) | NgModule Setup | NAuthModule.forRoot(), class-based guards |
| React | Setup & Context | AuthContext, useAuth hook, ProtectedRoute |
| Mobile (Capacitor) | Capacitor Setup | Native storage, dual-mode config |
| Other frameworks | Getting Started | Generic SDK setup for any JS/TS app |
Features
| Feature | Description |
|---|---|
| Standalone | No runtime dependency on @nauth-toolkit/core; all types bundled |
| Token Delivery | JSON or cookies mode with automatic handling |
| Challenge System | Unified respondToChallenge() for all verification flows |
| MFA Support | Setup, verify, and manage MFA devices |
| Social Auth | OAuth flow initiation and callback handling |
| Cross-Tab Sync | Token state synchronized across browser tabs (JSON mode) |
| SSR-Safe | Interceptor safely skips auth logic during server rendering |
| Framework Adapters | Angular bindings included; React patterns documented |
Token Delivery Modes
| Mode | Storage | Use Case |
|---|---|---|
cookies | HTTP-only cookies | Web applications |
json | Client storage | Mobile/native apps |
See Token Management for details on refresh, cross-tab sync, and security.
Feature Guides
- Challenge Handling - Email verification, MFA, password change flows
- MFA Setup - Add TOTP, SMS, Email, Passkey, backup codes
- Social Authentication - Web OAuth and native mobile login
- Error Handling - Error codes, retry, rate limiting
- Authentication Events - Subscribe to auth lifecycle events
- Admin Operations - User management from the frontend
Concepts
- Configuration - All SDK options, callbacks, endpoints
- Token Management - Token storage, refresh, cross-tab sync
API Reference
- NAuthClient - Complete client API
- NAuthClientConfig - Configuration interface
- NAuthClientError - Error handling
- Challenge Helpers - Utility functions
- Types - TypeScript type definitions
Related Documentation
- Backend API Reference - Direct backend integration
- Challenge System - Understanding challenge flows
- Token Management - Backend token configuration