Task 3: Build the Frontend
In this task, you will create an app frontend and connect it to the cloud backend you have already built
Introduction
Implementation
Install the Amplify libraries
You will need two Amplify libraries for your project. The main aws-amplify library contains all of the client-side APIs for connecting our app's frontend to our backend, and the @aws-amplify/ui-react library contains framework-specific UI components.
1. Install the libraries
Open a new terminal window, navigate to your projects root folder (expensetracker), and run the following command to install these libraries in the root of the project.
npm install aws-amplify @aws-amplify/ui-react

Style the App UI
Index.css
Replace your CSS with this CSS
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color: rgba(255, 255, 255, 0.87);
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}
.box:nth-child(3n + 1) {
grid-column: 1;
}
.box:nth-child(3n + 2) {
grid-column: 2;
}
.box:nth-child(3n + 3) {
grid-column: 3;
}
Implement the UI flow for Expenses feature
In this step, you will update the src/App.jsx file to configure the Amplify library with the client configuration file (amplify_outputs.json). Then, it will generate a data client using the generateClient() function.
The code uses the Amplify Authenticator component to scaffold out an entire user authentication flow allowing users to sign up, sign in, reset their password, and confirm sign-in for multifactor authentication (MFA).
Additionally, the code contains the following:
A code to use a real-time observeQuery to subscribe to a live feed of the user’s expenses data.
createExpense - Get the data from the form and use the data client to create a new expense.
deleteExpense - Use the data client to delete the selected expense.
1. Update the App.jsx file
On your local machine, navigate to the expensetracker/src/app.jsx file.
Replace the code in the App.jsx with the code from this file. Then, save the updated file.

2. Launch the app
Open a new terminal window, navigate to your projects root folder (expensetracker), and run the following command to launch the app:
npm run dev
3. Open the app
Select the Local host link to open the Vite + React application.

4. Create an account
Choose the Create Account tab, and use the authentication flow to create a new user by entering your email address and a password.
Then, choose Create Account.

5. Enter verification code
You will get a verification code sent to your email.
Enter the verification code to log into the app.

6. Create and delete expenses
When signed in, you can start creating expenses and delete them.

Conclusion
Deploy the App
Did you find what you were looking for today?
Let us know so we can improve the quality of the content on our pages