diff --git a/src/pages/[platform]/build-a-backend/auth/set-up-auth/index.mdx b/src/pages/[platform]/build-a-backend/auth/set-up-auth/index.mdx index 0b14f810977..d2bcb10aa76 100644 --- a/src/pages/[platform]/build-a-backend/auth/set-up-auth/index.mdx +++ b/src/pages/[platform]/build-a-backend/auth/set-up-auth/index.mdx @@ -100,7 +100,7 @@ Creating and correctly implementing the sign-in flow can be challenging and time 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 `@aws-amplify/ui-react` library: @@ -108,9 +108,38 @@ First, install the `@aws-amplify/ui-react` library: npm add @aws-amplify/ui-react ``` + + +Next, open **pages/App.tsx** and add the `Authenticator` component. + +```tsx title="pages/App.tsx" +import { Authenticator } from '@aws-amplify/ui-react'; +import { Amplify } from 'aws-amplify'; +import outputs from '../amplify_outputs.json'; +import '@aws-amplify/ui-react/styles.css'; + +Amplify.configure(outputs); + +export default function App() { + return ( + + {({ signOut, user }) => ( +
+

Hello {user?.username}

+ +
+ )} +
+ ); +}; +``` + +
+ + Next, open **pages/\_app.tsx** and add the `Authenticator` component. -```ts title="pages/_app.tsx" +```tsx title="pages/_app.tsx" import type { AppProps } from 'next/app'; import { Authenticator } from '@aws-amplify/ui-react'; import { Amplify } from 'aws-amplify'; @@ -134,6 +163,7 @@ export default function App({ Component, pageProps }: AppProps) { }; ``` +
@@ -183,7 +213,7 @@ npm add @aws-amplify/ui-components Now open **src/main.ts** and add the following below your last import: -```js title="src/main.ts" +```ts title="src/main.ts" import '@aws-amplify/ui-components'; import { applyPolyfills, @@ -204,7 +234,7 @@ Next, open **src/App.ts** and add the `amplify-authenticator` component. The `amplify-authenticator` component offers a simple way to add authentication flows into your app. This component encapsulates an authentication workflow in the framework of your choice and is backed by your backend Auth resources. The optional `amplify-sign-out` component is available if you would like to render a sign-out button. -```html title="src/App.ts" +```html title="src/App.vue"