Amplify Auth is powered by Amazon Cognito. Cognito is a robust user directory service that handles user registration, authentication, account recovery, and other operations. Review the concepts to learn more.
To get started with defining your authentication resource, open or create the auth resource file:
By default, your auth resource is scaffolded using email
as the default login mechanism. You can also configure your auth resource to allow signing in with phone numbers or an external provider such as Google, Facebook, Amazon, or Sign in with Apple.
Note: At a minimum you will need to pass a loginWith
value to set up how your users sign in to your app. Signing in with email and password is configured by default if you do not provide any value.
After you have chosen and defined your authentication resource, run the following command to create your resource in your personal cloud sandbox.
After a successful deployment, this command also generates an outputs file (amplify_outputs.json
) to enable your frontend app to connect to your backend resources. The values you configure in your backend authentication resource are set in the generated outputs file to automatically configure the frontend Authenticator connected component
.
Creating and correctly implementing the sign-in flow can be challenging and time-consuming. Amplify's Authenticator UI component streamlines this by enabling you to rapidly build the entire authentication flow for your app. The component works seamlessly with configuration in amplify/auth/resource.ts
to automatically connect with your backend resources.
Amplify has pre-built UI components for React, Vue, Angular, React Native, Swift, Android, and Flutter. In this guide, we are focusing on those for web applications.
First, install the amplify_authenticator
library:
or you can update your pubspec.yaml
file with the following
and run the following command to download the libraries.
Next, update your main.dart
file with the following:
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_authenticator/amplify_authenticator.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:flutter/material.dart';
import 'amplify_outputs.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await _configureAmplify();
} on AmplifyException catch (e) {
runApp(Text("Error configuring Amplify: ${e.message}"));
Future<void> _configureAmplify() async {
await Amplify.addPlugin(AmplifyAuthCognito());
await Amplify.configure(amplifyConfig);
safePrint('Successfully configured');
} on Exception catch (e) {
safePrint('Error configuring Amplify: $e');
class MyApp extends StatelessWidget {
const MyApp({super.key});
Widget build(BuildContext context) {
builder: Authenticator.builder(),
mainAxisAlignment: MainAxisAlignment.center,
Once you add the Authenticator component to your app, you can test the sign-up, sign-in, and sign-out functionality. You can also customize the Authenticator connected component to adjust colors and styling as needed.
Next stepsNow that you have completed setting up authentication in your Amplify app with email and password, you may also want to add some additional features. We recommend you learn more about:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4