better_auth_flutter
0.1.2, released 3 months ago by stormej.me
Flutter SDK for Better Auth providing email/password, social sign‑in, session management and reactive auth state.
What it does
It wraps Better Auth's REST API with a Dio client, handling authentication flows, cookie or bearer sessions, and exposing a sealed Result type for all calls. It also offers Riverpod 3 providers and streams to reactively track auth state.
AI-written summary of version 0.1.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need a custom backend authentication solution rather than Firebase or Supabase
- You want reactive auth state with Riverpod or Stream listeners
- You require secure cookie‑based sessions across platforms
Skip it when
- You only need simple OAuth with Google/Apple and don't need a full backend
- You prefer a fully managed BaaS like Firebase
Strengths
- Unified API for email, password, social and passkey auth
- Reactive auth state via streams and Riverpod providers
- Secure cookie storage with automatic persistence
Weaknesses
- Tied to Better Auth backend; not a generic OAuth library
- Requires manual setup of the Better Auth server
- No code generation; models must be maintained manually
Setup
- Kind
- Flutter widgets
- Effort
- Medium
- Code generation
- Yes (build_runner)
- Direct dependencies
- 16
Add the package, call BetterAuthFlutter.initialize with your server URL before runApp; no native permissions required
import 'package:better_auth_flutter/better_auth_flutter.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await BetterAuthFlutter.initialize(url: 'https://example.com/api/auth');
runApp(const MyApp());
}
Future<void> signIn() async {
final result = await BetterAuthFlutter.client.signInEmail(email: 'user@example.com', password: 'secret');
result.when(
success: (data) => print('Welcome ${data.user?.name}'),
failure: (error) => print('Error: ${error.message}'),
);
}Alternatives
Packages that do the same job and could replace better_auth_flutter.
- firebase_auth
Provides similar auth features with a fully managed backend and extensive Firebase ecosystem
99Compare - google_sign_in
Simpler if you only need Google OAuth without a custom backend
84Compare - sign_in_with_apple
Dedicated Apple sign‑in without needing the full Better Auth server
86Compare
Works with
Packages commonly used together with better_auth_flutter: ones it builds on, ones built on it, and its own family.
- webbetter_auth_flutter depends on itLightweight bindings for browser APIs via JS interop
- json_annotationbetter_auth_flutter depends on itProvides annotations for json_serializable to generate JSON (de)serialization code.
- path_providerbetter_auth_flutter depends on itProvides Flutter APIs to locate common filesystem directories on Android, iOS, macOS, Linux and Windows.
- shared_preferencesbetter_auth_flutter depends on itFlutter plugin for reading and writing simple key-value pairs. Wraps NSUserDefaults on iOS and SharedPreferences on Android.
- flutter_secure_storagebetter_auth_flutter depends on itSecure key-value storage using platform-specific secure mechanisms
- diobetter_auth_flutter depends on itA powerful HTTP networking package for Dart and Flutter with interceptors and request cancellation.
- freezed_annotationbetter_auth_flutter depends on itAnnotations for the freezed code-generator.
- connectivity_plusbetter_auth_flutter depends on itDiscover the state of network connectivity (WiFi, mobile, ethernet) on Android, iOS, Web and desktops.