better_auth_flutter
A Flutter client package for integrating with Better Auth - a secure authentication platform.
What this package is like to depend on
Last release 1 months ago
24 Jul 2026
Ships unpredictably
gaps range from 9 days to 13 months
Nearly every release is documented
notes for 8 of 8 stable releases
Nothing withdrawn
no release was ever pulled
1 years old
8 releases · first in 2025
1 release in the last 12 months
see the full history below
Release timeline
8 releases · Apr 2025 to Jul 2026Releases
latest 8-
0.1.024 Jul 2026Release notes
Open source →Security fixes, a reachable public API, reactive auth state, and working bearer mode.
This release is breaking. Every breaking change is bundled here so you migrate once. See the migration table at the end.
Added
-
Bearer authentication that actually works.
initialize(mode: AuthMode.bearer)captures the token from theset-auth-tokenresponse header and sends it asAuthorization: Bearer. Previously nothing read that header, so bearer mode could not obtain a token at all.TokenStorage<String>(defaultInMemoryTokenStorage) controls persistence, andBearerOptions.requireSignatureis now honored. -
Session refresh.
BetterAuthFlutter.refreshSession()(single-flight), automatic refresh on app resume viaBetterAuthProvider(throttled;refreshOnResume: falseto opt out), and transparentdeferSessionRefreshhandling (SessionResponse.needsRefresh→ follow-up POST). -
SecureStorage, backed byflutter_secure_storagewith iOS keychain chunking — now the default cookie store on native platforms. Hive and SharedPreferences remain available as opt-in backends. -
Typed social sign-in.
SocialProviderenum andSignInSocialBody;signInSocialnow takes the typed body, withsignInSocialRawfor providers outside the enum (e.g.genericOAuth). -
Browser-redirect social sign-in.
initialize(callbackUrlScheme:)andBetterAuthFlutter.signInWithProvider(...)drive theflutter_web_auth_2flow and return a parsedSocialCallback(with the one-time-token handoff for cookie-mode sessions). The dependency was declared but unused before. -
New plugins:
two_factor(typed TOTP / OTP / backup codes),anonymous,magic_link,api_key,organization,multi_session, andone_time_token.SignInEmailResponsegainedtwoFactorRedirect(anduseris now nullable) so callers can branch on a 2FA challenge. -
A runnable
example/app (email/password, reactive gating, sign-out). -
A barrel file.
import "package:better_auth_flutter/better_auth_flutter.dart"now resolves. It previously did not exist, so every snippet in the README and docs failed to compile and consumers had to deep-import implementation paths. -
Reactive auth state.
BetterAuthFlutter.authStateChanges(Stream<AuthState>),BetterAuthFlutter.onAuthChange(Stream<User?>), andBetterAuthFlutter.authStatefor a synchronous read. State updates automatically on sign-in, sign-up, sign-out, session refresh, and any 401. The stream replays current state to new listeners, so subscribing late still reports where things stand. -
BetterAuthBuilder— a declarative auth gate withauthenticated/unauthenticated/loading/errorbranches.AuthInitialis distinct fromUnauthenticated, so the sign-in screen no longer flashes during cold start while the stored session loads. -
BetterAuthFlutter.refreshSession()andinitialize(hydrateOnInit:)to look the stored session up on startup (in the background — it does not blockmain()). -
Per-plugin libraries:
package:better_auth_flutter/plugins/<name>.dartfor admin, bearer, email_otp, jwt, and phone. Admin and bearer previously had no barrel at all. -
BetterError.statusCode, plusisUnauthorized/isNetworkError. Failures could not previously be told apart by status. -
Transport-level error codes (
NETWORK_ERROR,TIMEOUT,CANCELLED,BAD_RESPONSE,UNAUTHORIZED,RATE_LIMITED) for failures carrying no Better Auth error body. SeeBetterErrorCodes. -
StorageInterface.deleteCookies(url)/deleteAll(), andBetterAuthFlutter.clearCookies(). -
First test suite (70 tests) and CI.
Security
- Session cookies are no longer logged. The API adapter logged full response
headers — including
Set-Cookie— on every failed request, in release builds. Internal logging is now off by default and never logs headers, cookies, or bodies. Opt in withBetterAuthFlutter.initialize(enableLogging: kDebugMode). Securecookies are no longer sent over plain HTTP, and expired cookies are no longer sent at all.CustomPersistCookieJar.loadForRequestreturned cookies straight from the durable store without applying any scoping. (The underlyingcookie_jarfilter is also unreliable here, so thesecureand expiry rules are now enforced directly.)
Fixed
- Users are no longer signed out on every cold start.
HiveStoragewrote cookieexpiresas aDateTimebut read it back as anint, throwing on load. Every Better Auth session cookie carries anExpiresattribute, so no persisted session survived a restart. Cookie serialization now lives in one shared, tested codec used by every storage backend, and tolerates rows written by previous versions instead of crashing. - API methods no longer throw. The adapter did
response.data["code"], which throws on a non-Map body (an HTML error page from a proxy, for example) — from inside its owncatch, so the exception escapedResultentirely. Non-Map,List, and null bodies now all produce aFailure. - Sign-out now clears the durable cookie store as well as the in-memory jar, via
the new
BetterAuthFlutter.clearCookies(). Previously the store kept the session cookie indefinitely. - Cookies persist correctly when no custom store is configured; previously this configuration returned no cookies at all.
Changed
- Internals moved from
lib/source/tolib/src/. Import the barrel instead. BetterAuthConsumer's builder now receives the currentAuthStateas a third argument.BetterAuthProvidernow subscribes to auth state, so descendants rebuild when the session changes.- Plugin getters (
client.jwt,client.admin, …) are cached per client instead of constructing a new HTTP client on every property access.
Migration
Before After import "package:better_auth_flutter/source/core/api/client/better_auth_client.dart";import "package:better_auth_flutter/better_auth_flutter.dart";deep source/plugins/...importsimport "package:better_auth_flutter/plugins/jwt.dart";BetterAuthConsumer(builder: (context, client) => …)BetterAuthConsumer(builder: (context, client, state) => …)StorageInterfacewith 2 methods4 methods — add deleteCookiesanddeleteAlldefault store HiveStorage(plaintext)SecureStorage(keychain) — existing users sign in once after upgradecreateDioWithBearer(...)/dio.useBearerAuth(...)initialize(mode: AuthMode.bearer, tokenStorage: …)logging always on off unless initialize(enableLogging: true)polling getSession()for auth stateauthStateChanges/BetterAuthBuilderSigning out should now also call
BetterAuthFlutter.clearCookies()to clear the persisted session.Existing
StorageInterfaceimplementations must add the two new methods. If you relied on cookies persisting across restarts, note that this never actually worked with the default backend (see above) — users will sign in once after upgrading. -
-
0.0.729 Jun 2025 -
0.0.626 Jun 2025 -
0.0.525 May 2025Release notes
Open source →- Add Social Sign In With All Providers (Redirection to be handled, using something like flutter_web_auth_2)
- Added multiple social providers
-
0.0.415 May 2025 -
0.0.303 May 2025 -
0.0.227 Apr 2025 -
0.0.122 Apr 2025