import { useRef } from 'react'; import classNames from 'classnames'; import { Flex, Heading, Text, Link, View, Authenticator, useBreakpointValue, } from '@aws-amplify/ui-react'; import { HomeCode } from '@/components/home/HomeCode'; import { HomeCTA } from '@/components/home/HomeCTA'; import { CodeHighlight } from '@/components/CodeHighlight'; import { useIntersectionObserver } from '@/components/useIntersection'; import { FlutterAuthenticatorExample } from '@/components/FlutterAuthenticatorExample'; import { BrowserMock } from '@/components/home/BrowserMock'; import { trackScroll } from '@/utils/track'; import { ExpoSnack, ExpoSnackWithExports } from '@/components/ExpoSnack'; // TODO: grab this code from actual examples so we don't need to keep these in sync const authenticatorCode = { angular: `

Welcome {{ user.username }}!

`, react: `import { Amplify } from 'aws-amplify'; import { Authenticator } from '@aws-amplify/ui-react'; import '@aws-amplify/ui-react/styles.css'; import awsExports from './aws-exports'; Amplify.configure(awsExports); export default function App() { return ( {({ signOut, user }) => (

Hello {user.username}

)}
); }`, vue: ` `, flutter: `class MyApp extends StatefulWidget { const MyApp({super.key}); @override State createState() => _MyAppState(); } class _MyAppState extends State { @override void initState() { super.initState(); _configureAmplify(); } void _configureAmplify() async { try { await Amplify.addPlugin(AmplifyAuthCognito()); await Amplify.configure(amplifyconfig); safePrint('Successfully configured'); } on Exception catch (e) { safePrint('Error configuring Amplify: $e'); } } @override Widget build(BuildContext context) { return Authenticator( child: MaterialApp( builder: Authenticator.builder(), home: const Scaffold( body: Center( child: Text('You are logged in!'), ), ), ), ); } }`, 'react-native': `import React from 'react'; import { Button } from 'react-native'; import { Amplify } from 'aws-amplify'; import { Authenticator, useAuthenticator } from '@aws-amplify/ui-react-native'; import awsExports from './aws-exports'; Amplify.configure(awsExports); function SignOutButton() { const { signOut } = useAuthenticator(); return