Nest Authbeta

Flutter / Dart

Full reference for the `nest_auth_flutter` package.

nest_auth_flutter is a small, dependency-light Flutter / Dart SDK for @ackplus/nest-auth: HTTP auth flows, secure token storage, and transparent token refresh. The core NestAuthClient is pure Dart; SecureTokenStorage wraps flutter_secure_storage for production apps.

Tokens are returned in the response body and sent in the Authorization header — so the backend must run in header token mode. The client attaches the access token to authenticated requests and, on a 401, transparently refreshes once and retries. For reactive UIs, the NestAuthController (ChangeNotifier) rebuilds your widgets on login and logout.

Sections

  • Getting Started — install, backend setup, creating a NestAuthClient, and token storage adapters.
  • Authentication — signup, email / password, passwordless, and social login; logout; password reset; email & phone verification; change password.
  • MFA & Tenancy — the MFA challenge / verify flow, reading MFA status, and switchTenant.
  • Using it in your app — the reactive NestAuthController, a ListenableBuilder login-to-home example, and error handling with NestAuthException.

At a glance

import 'package:nest_auth_flutter/nest_auth_flutter.dart';
 
final auth = NestAuthClient(
  baseUrl: 'https://api.example.com',
  storage: SecureTokenStorage(), // keychain / keystore-backed
);
 
await auth.loginWithEmail('a@b.com', 'secret'); // tokens persisted automatically
 
if (await auth.isAuthenticated) {
  final user = await auth.getSessionUserData();
  print(user.email);
}
 
await auth.logout();

On this page