Getting Started
Installation
Add Authyra to your Dart or Flutter project.
Requirements
- Dart SDK ≥ 3.5.0
Choose your package
Authyra ships as two packages. Pick the one that matches your target:
| I'm building… | Add this package |
|---|---|
| A Flutter app with OAuth2 (Google, GitHub, Apple…) | authyra_flutter |
| A Flutter app with email/password only | authyra_flutter or authyra |
| A Dart backend (Shelf, Dart Frog) | authyra |
| A Dart CLI tool | authyra |
| Unit tests for auth logic | authyra |
authyra_flutter re-exports the entire authyra package, so Flutter apps only need one dependency.
Flutter apps — authyra_flutter
pubspec.yaml
dependencies:
authyra_flutter: ^0.1.0
flutter pub get
This gives you:
| What | Description |
|---|---|
AuthyraClient | Stateless orchestrator |
AuthyraInstance / Authyra | Singleton with reactive streams and sync state |
AuthProvider interface | Implement to add any auth strategy |
AuthStorage interface | Implement any persistence backend |
CredentialsProvider | Email / password |
OAuth2Provider | Authorization Code + PKCE (any IdP) |
GoogleProvider | Prebuilt Google Sign-In |
GitHubOAuth2Provider | Prebuilt GitHub OAuth |
AppleProvider | Sign in with Apple |
ProxyOAuthProvider | Backend-delegated OAuth (client secret stays server-side) |
SecureAuthStorage | flutter_secure_storage implementation — ready to use |
OAuth2CallbackHandler | Deep-link router for OAuth redirects |
InMemoryStorage | In-memory store for tests |
AccountManager | Multi-account switching and sign-out |
Dart backend / CLI — authyra
pubspec.yaml
dependencies:
authyra: ^0.1.0
dart pub get
This gives you everything above except the OAuth2 providers, SecureAuthStorage, and OAuth2CallbackHandler (those depend on Flutter and platform APIs).
For backend auth flows, implement AuthProvider to talk to your identity server and implement AuthStorage with Redis, an encrypted DB column, or any key-value store.
Verify the install
import 'package:authyra/authyra.dart'; // or authyra_flutter
void main() {
print(AuthyraInstance.isInitialized); // false — not yet initialized
}