@ackplus/nest-auth-client
| Install | |
|---|---|
npm install @ackplus/nest-auth-client |
|
| Latest Version: | 2.14.0 |
| License: | MIT |
| Last Updated: | Oct 12, 2026 |
| Links: | GitHub · npm |
@ackplus/nest-auth-client
Framework-agnostic JavaScript/TypeScript client for @ackplus/nest-auth. Zero peer dependencies. Works anywhere modern JS runs — browsers, Node 18+, React Native, Cloudflare Workers, Deno, Bun.
📚 Full documentation: ack-solutions.github.io/nest-auth/docs/client
Why use it
The official client for the @ackplus/nest-auth backend. Use it directly from Vue, Angular, Svelte, vanilla JS, or as the foundation under @ackplus/nest-auth-react.
It handles the parts of auth that are tedious to write by hand: token persistence, automatic refresh on 401 with concurrent-request deduplication, cookie/header mode switching, MFA flows, multi-tenant context, and an event subscription API.
Install
pnpm add @ackplus/nest-auth-client
No peer dependencies. TypeScript definitions ship in the package.
Minimal example
import { AuthClient } from '@ackplus/nest-auth-client';
const auth = new AuthClient({
baseUrl: 'https://api.example.com',
});
await auth.signup({
email: 'alice@example.com',
password: 'correct horse battery staple',
firstName: 'Alice', // any extra field flows through to UserRegisteredEvent
});
await auth.login({
credentials: { email: 'alice@example.com', password: 'correct horse battery staple' },
});
if (auth.getIsAuthenticated()) {
const user = await auth.getSessionUserData();
console.log('Hello', user.email);
}
What's included
| Capability | Notes |
|---|---|
| Auth flows | signup, login, logout, logoutAll, refresh, passwordlessSend, switchTenant |
| MFA | send2fa, verify2fa, setupTotp, verifyTotpSetup, getMfaStatus, recovery codes |
| Password management | forgotPassword, verifyForgotPasswordOtp, resetPassword, changePassword |
| Email/phone verification | sendEmailVerification, verifyEmail, sendPhoneVerification, verifyPhone |
| Auto-refresh | 401 → refresh → retry once, with RefreshQueue deduplication so N parallel 401s only fire one refresh |
| Header or cookie mode | accessTokenType: 'header' | 'cookie' | null (auto-detect) |
| Storage adapters | MemoryStorage, LocalStorageAdapter, SessionStorageAdapter, CookieStorageAdapter, custom |
| HTTP adapters | FetchAdapter (default) or createAxiosAdapter(yourAxiosInstance), custom |
| Events | onTokensSet, onTokenRefreshed, onTokensRemoved, onLogout, onError, onSessionVerified |
| Utilities | decodeJwt, isTokenExpired, hasRole, hasPermission, hasAnyAccess, hasAllAccess |
Configuration
new AuthClient({
baseUrl: 'https://api.example.com',
storage: new LocalStorageAdapter('myapp_'),
httpAdapter: new FetchAdapter(),
accessTokenType: 'header', // or 'cookie' or null (auto-detect)
autoRefresh: true,
refreshThreshold: 60, // seconds before expiry
onTokenRefreshed: (tokens) => { /* … */ },
onLogout: () => { window.location.href = '/login'; },
onError: (err) => console.error(err),
});
React Native
import AsyncStorage from '@react-native-async-storage/async-storage';
import { AuthClient, type StorageAdapter } from '@ackplus/nest-auth-client';
const RNStorage: StorageAdapter = {
get: (k) => AsyncStorage.getItem(k),
set: (k, v) => AsyncStorage.setItem(k, v),
remove: (k) => AsyncStorage.removeItem(k),
clear: () => AsyncStorage.clear(),
};
export const auth = new AuthClient({
baseUrl: 'https://api.example.com',
storage: RNStorage,
});
Documentation
| Section | What's there |
|---|---|
AuthClient |
Every method with TS signatures and examples |
| Config | All AuthClientConfig options |
| Storage Adapters | Built-ins and how to write your own |
| HTTP Adapters | Fetch (default), axios, custom |
| Events | Subscription API |
| Utilities | JWT helpers, role/permission checks |
Companion packages
| Package | Use when |
|---|---|
@ackplus/nest-auth |
The NestJS backend module |
@ackplus/nest-auth-react |
React provider, hooks, guards, and Next.js App Router helpers (recommended for React) |
@ackplus/nest-auth-contracts |
Shared TS types (already a transitive dep of this package) |
All four packages release together with the same version number. Pin them all to the same version.
Links
License
Related Packages
Framework-agnostic query builder for REST APIs - build complex queries with filt...
TypeScript GraphQL client for Propeller eCommerce V2 Platform - works with React...
Version History
| Version | Released | License |
|---|---|---|
| 2.14.0 | MIT | |
| 2.13.1 | MIT | |
| 2.13.0 | MIT | |
| 2.12.0 | MIT | |
| 2.11.1 | MIT | |
| 2.11.0 | MIT | |
| 2.10.4 | MIT | |
| 2.10.3 | MIT | |
| 2.10.2 | MIT | |
| 2.10.1 | MIT | |
| 2.10.0 | MIT | |
| 2.9.2 | MIT | |
| 2.9.1 | MIT | |
| 2.9.0 | MIT | |
| 2.8.5 | MIT | |
| 2.8.4 | MIT | |
| 2.8.3 | MIT | |
| 2.8.2 | MIT | |
| 2.8.1 | MIT | |
| 2.8.0 | MIT | |
| 2.7.6 | MIT | |
| 2.7.5 | MIT | |
| 2.7.4 | MIT | |
| 2.7.3 | MIT | |
| 2.7.2 | MIT | |
| 2.7.1 | MIT | |
| 2.7.0 | MIT | |
| 2.6.0 | MIT | |
| 2.5.2 | MIT | |
| 2.5.1 | MIT |
Showing the latest 30 of 75. See every release on npm
Pre-releases (31)
| Version | Released | License |
|---|---|---|
| 2.0.0-beta.26 | MIT | |
| 2.0.0-beta.25 | MIT | |
| 2.0.0-beta.23 | MIT | |
| 2.0.0-beta.22 | MIT | |
| 2.0.0-beta.21 | MIT | |
| 2.0.0-beta.20 | MIT | |
| 2.0.0-beta.19 | MIT | |
| 2.0.0-beta.18 | MIT | |
| 2.0.0-beta.16 | MIT | |
| 2.0.0-beta.15 | MIT | |
| 2.0.0-beta.13 | MIT | |
| 2.0.0-beta.12 | MIT | |
| 2.0.0-beta.10 | MIT | |
| 2.0.0-beta.9 | MIT | |
| 2.0.0-beta.8 | MIT | |
| 2.0.0-beta.7 | MIT | |
| 2.0.0-beta.6 | MIT | |
| 2.0.0-beta.4 | MIT | |
| 2.0.0-beta.3 | MIT | |
| 2.0.0-beta.2 | MIT | |
| 2.0.0-beta.1 | MIT | |
| 1.1.69-beta.9 | MIT | |
| 1.1.69-beta.8 | MIT | |
| 1.1.69-beta.2 | MIT | |
| 1.1.31-beta.15 | MIT | |
| 1.1.31-beta.14 | MIT | |
| 1.1.31-beta.13 | MIT | |
| 1.1.31-beta.12 | MIT | |
| 1.1.31-beta.11 | MIT | |
| 1.1.31-beta.10 | MIT |
Showing the latest 30 of 31. See every release on npm