Adding Amplify UI components to a ReactJS project
Let's open the App.tsx
file of our ReactJS project. We will add the following TypeScript code to the app:
- As usual, import the essential React and Amplify libraries as well as the
App.css
file:import React from 'react'; import './App.css'; import Amplify from 'aws-amplify';
- Import the
AmplifyAuthenticator
andAmplifySignOut
UI components. We will integrate the sign in, sign up, and sign out UI components first:import { AmplifyAuthenticator, AmplifySignOut } from '@aws-amplify/ui-react'; import { AuthState, onAuthUIStateChange } from '@aws-amplify/ui-components';
- Import the AWS setting file. Please make sure that you don't commit the
aws-export.js
or.ts
setting files to the Git repository because the AWS console will figure it out itself:import awsExports from "./aws-exports"; Amplify.configure(awsExports); const App = () => {
- We will create...