
~/.aws/config) has the AmplifyBackendDeployFullAccess permissions.
(If you prefer not to use SSO, you could create an IAM user with equivalent policies, but the above is the recommended approach for Amplify Gen 2.)amplify/ folder with predefined backend resources (a to-do database and authentication). Give your new repo a name (e.g., “amplify-todo-app”) and create it.














https://main.branchid.amplifyapp.com (Amplify provides a default domain). You can click “Visit deployed URL” to see the live app. It should load a basic to-do app interface (with a prompt to sign in, since auth is enabled). At this point, the app’s backend (API, database, auth) is up in the cloud, and the front-end is hosted. 🎉







amplify/ directory contains your backend “stack” defined in TypeScript – you can add to this to create new backend resources. The src/ is your React application. Amplify Gen 2 projects keep frontend and backend code together for a cohesive full stack project.npx create-react-app or Vite) and then add Amplify to it. This involves installing Amplify libraries (npm install @aws-amplify/backend@latest @aws-amplify/backend-cli@latest) and running npm create amplify@latest to scaffold the amplify/ folder. Then you’d define your data model in code and deploy. This approach gives more insight into each step, but for beginners the starter template (Option A) is simpler, as it gives you a working app to start with. In this guide, we followed the template approach, since it quickly gets us to a point where the app is running, and we can focus on features.package.json file lists all the dependencies required for the project.

package.json file and installs all the required packages into the node_modules directory. Additionally, it ensures that the versions specified in package-lock.json are maintained, ensuring consistency across different environments.amplify/auth/resource.ts) using Amazon Cognito. By default, it is set up to allow users to sign up and sign in with an email and password (you could extend it to social providers or multi-factor auth later).src/main.tsx. This is where the React app is initialized. We need to wrap our <App /> component with the <Authenticator> from Amplify UI and configure Amplify with our backend settings. For example:
amplify_outputs.json which contains all the identifiers and endpoints for our cloud resources (API URL, region, User Pool ID, etc.).Amplify.configure(outputs) to initialize the Amplify client library with those details.<Authenticator> – this automatically provides a login screen if the user is not signed in, and if they are signed in it will show the App content. Amplify UI handles the state transitions, form validation, and integration with the Cognito auth service.amplify_outputs.json to connect to the backend.)



npm install (if you haven’t done so already as described) and npm start (or npm run dev for Vite as in our case). Your app will compile and open at http://localhost:3000 or http://localhost:5173 (for Vite). You should see the to-do UI.



<Authenticator> component. This component automatically provides a complete authentication flow (sign-up, sign-in, password reset, etc.) without writing the forms manually. We must import the Authenticator UI as shown below if we want users to first log in using their user profiles, in our own project is email as shown above.

<App />) is displayed.npm run dev or refresh your browser where your local host is running). Open your browser and navigate to your local host address. You should see the login interface provided by Amplify. Interact with the Authenticator, try signing up or signing in. The UI should smoothly transition from the login forms to your main app upon successful authentication. We also added two more Todo’s to the list.



amplify/data/resource.ts file, you’ll find a schema defined using Amplify’s Data Modeling API. For example, a simple Todo model could be defined like:
content. When Amplify deploys, it creates a DynamoDB table for Todo items and generates a GraphQL API (via AWS AppSync) with queries, mutations, and subscriptions for the Todo model. The front-end can use Amplify’s DataStore or API client to interact with this model – for example, create new todos, list todos, etc., without writing any server code. The starter project’s todo model was set up for real-time updates, meaning whenever a todo is added or deleted, all clients get updated via WebSocket (AppSync subscriptions).

npx ampx sandbox for testing in a temporary environment, then commit and push to deploy) to apply it. However, we will do this in the next steps.amplify/ directory. For example, adding a file storage would create an amplify/storage folder with its config, etc. The Amplify CLI (amplify pull, ampx commands) helps generate these resources.
npm ampx sandbox leverages Amplify Gen2’s local setup to create a temporary (sandbox) environment in the cloud that mirrors your backend configuration. You’ll be prompted for some inputs, such as “Select an AWS profile” or “Use the default environment name?” This environment will be separate from any existing main or dev environment.npm ampx sandbox might show messages like:aws configure sso or aws configure). After configuring, re-run npm ampx sandbox. You will get a confirmation from Amplify as it pops with the message:

npm ampx sandbox, type something unique like “sandbox2”), or delete the previous sandbox environment in the Amplify Console before re-creating it.aws sso login --profile <YourProfile> or aws configure sso to refresh the session, then re-run the sandbox deployment.resource.ts has syntax errors or invalid schema rules, Amplify might throw an error. For instance:amplify/data/resource.ts, making sure each field type is supported (e.g., a.string(), a.int(), etc.). Then rerun npm ampx sandbox.
amplify_outputs.json specific to the sandbox or configuring your front-end to point to the new endpoint. This lets you test out the new schema changes in a local environment without messing with your main or production environment.amplify/ folder and pushing to the repository. At that point, your main environment will be updated with the changes validated in the sandbox.
amplify/data/resource.ts

src/App.tsx) and import Amplify’s authentication hook:

amplify_outputs.json file, containing your backend details.App.tsx, which we can refine. Let’s outline what the React code does and how to modify/extend it:App.tsx, the code likely uses Amplify’s generated data client to fetch and subscribe to todos. Amplify Gen 2’s data library can generate a client (e.g., client.models.Todo) to interact with the Todo model. The starter app, for example, has:
todos state. We render this as a list of <li> items. Each to-do item displays its content text. If we implemented owner-based auth, users would only receive their own items from the API.client.models.Todo.create({ content: "task text" }) to save a new item. This triggers the backend to save to DynamoDB and notify all subscribers (including our app) of the new item, updating the list in real time.deleteTodo(id) function that calls client.models.Todo.delete({ id }). In the UI, they set each <li> to listen for click and call delete on its own ID. Our app can do the same – for instance, clicking a to-do could remove it. (In a real app, you might use a trash icon button for clarity instead of clicking the list item text.) Therefore, we updated the App.tsx with the code below to add the delete functionality.



index.css to adjust styles. For example, you might style the <h1> (title), the list items, and the new-task button to make the app look nice.Amplify.configure(outputs) call ties your app to the backend. The amplify_outputs.json file includes things like the GraphQL endpoint URL, the region, and the unique IDs of the resources. Amplify’s JS library uses this to know where to send API requests and how to talk to your Auth service. Always ensure you have the latest amplify_outputs.json when working in development, especially if you made changes to the backend.aws-amplify JS) stores the user’s credentials (JWT tokens) in memory. It will automatically attach these credentials to requests to authorized APIs. For example, our GraphQL requests include the user’s token, so the backend knows the identity (these ties into the owner-based auth rule we set, so it knows which user is owner).client.models.Todo helpers (as seen with .list(), .create(), etc.). Under the hood, these make GraphQL calls to AWS AppSync. The responses come back as JavaScript objects (Todo items) that our app can use directly. Real-time updates use WebSocket connections managed by Amplify; when a new Todo is created or deleted, the AppSync API broadcasts and the Amplify library invokes our subscription callback to update state.client.models.Todo) and Amplify handles the rest. This is a huge productivity boost for full-stack development.amplify push if backend changes, etc.), and then deploy the new version to the live site. This CI/CD workflow means you don’t manually FTP files or run deployment scripts – Amplify handles it.amplify/ directory) – e.g., add a new model or function – those changes will also get deployed when you push. Amplify uses a concept of Cloud Sandbox for safe development: you can test backend changes in an ephemeral environment (ampx sandbox) and then merge them. When you commit these changes, Amplify will update the cloud resources accordingly. Always commit the Amplify changes along with your frontend so that the backend and frontend stay in sync.git push to push our latest code to GitHub and then trigger the CI/CD automatically to our Amplify too.





auth, data, storage, functions under the amplify/ directory. Continue this pattern. For example, if you add another data model, it might go into the existing data/resource.ts (since Amplify supports multiple models in one schema). If you add Lambda functions, they will appear in amplify/functions/. Keeping infrastructure code version-controlled (which Amplify does) means your whole team can collaborate on it and you can rollback if needed. The Amplify project structure is designed to collocate related resources – e.g., you could place a post-confirmation trigger Lambda right next to your Cognito auth resource code.App.tsx can handle everything, but as you add features, create new component files and perhaps use a state management library if needed. Amplify’s UI library has many pre-built components that you can use (for example, Amplify UI React has theming, and primitives like <TextField>, <Button>, etc., which match AWS Amplify styles).ampx) makes it easy to spin up these envs. When ready, merge to main to update prod.@aws-amplify/backend-cli in Gen 2) ensures you have the latest features and fixes. Also, track Amplify’s announcements or docs for any changes (e.g., new data field types or new UI components).Posted Aug 30, 2025
Developed a full-stack To-Do app using React and AWS Amplify Gen2.
0
1