View a markdown version of this page

Tutorial: Deploy a website - AWS Amplify

Tutorial: Deploy a website

Welcome to the new AWS Amplify

Amplify now puts hosting, a Postgres database, and sign-in in one AWS account. Deploy from your terminal or from Git, check every change in a preview first, and roll back in one step if something breaks.

Looking for Amplify Hosting? See the Amplify Hosting User Guide.

This tutorial takes a few minutes, including setup. You create an app in your AWS account, deploy it to preview, and then deploy it to production.

Avoid charges

The app can incur charges while it exists. For the plans and their prices, see Pricing and spend limits. To avoid charges, delete the app when you finish. For instructions, see Clean up.

Prerequisites

You need the following:

  • AWS credentials for your AWS account, and permissions for Amplify. To check your credentials, run aws sts get-caller-identity. If the command fails, sign in with aws sso login or aws configure. For the permissions, see Give your account permissions.

  • The latest version of the AWS Command Line Interface (AWS CLI) v2, which includes the aws amplifygen3 subcommand. To check, run aws amplifygen3 help. If the command isn’t found, install or update the AWS CLI by following Installing or updating to the latest version of the AWS CLI in the AWS CLI User Guide.

  • Node.js 22.12 or later, and npm 10 or later. To check, run node --version and npm --version.

Secure your AWS account first

If your account is new, secure the root user with multi-factor authentication (MFA), and use an administrative IAM user or role instead of the root user for daily work.

Step 1: Set up your app

Create a Next.js app, and then initialize Amplify in it:

npx create-next-app@latest my-app cd my-app aws amplifygen3 local init

To use another framework that Amplify detects, such as React with Vite, Vue, or Angular, use your own app instead of the Next.js app. aws amplifygen3 local init detects the framework and fills in its build settings. For the list of frameworks, see Frameworks.

The local init command only creates files on your machine. Amplify doesn’t create anything in AWS until you deploy. The command names the app after the folder. To choose another name, add --app followed by the name.

You should see a new amplify.jsonc file in your app folder. The file’s deploy section tells Amplify how to build your website. For more information, see Configuration file.

Note

This tutorial uses the aws amplifygen3 commands. The npm create amplify and npx ampx sandbox commands are for Amplify Gen 2, not for AWS Amplify.

Step 2: Deploy to preview

Run the following command:

aws amplifygen3 deploy

The first deploy creates the app in your AWS account. The build runs in the cloud, from the deploy section of amplify.jsonc. Amplify doesn’t upload your local node_modules folder. When the deploy finishes, you should see your preview URL, such as https://preview-xxxx--my-app.amplify.app, where xxxx is the preview ID that Amplify assigns. Open the URL to see your website.

For Nuxt, Astro, and SvelteKit, deploy offers to install the framework adapter that the build needs. For the setup, see the page for your framework in Frameworks.

Step 3: Deploy to production

To deploy your app to production, run the following command. If you want to check your changes first, open your preview URL.

aws amplifygen3 deploy --env production

You should see your production URL, such as https://my-app.amplify.app. If another app already has the name, Amplify adds a random suffix, so use the URL from the deploy output. After you change your code, run aws amplifygen3 deploy again. The deploy command uses preview unless you add --env production.

Clean up

Your app and both of its environments stay in your AWS account until you delete them.

Deleting the app is permanent

The following command deletes the app and both of its environments. You can’t undo this action.

Run the following command. Replace my-app with the name of your app.

aws amplifygen3 app delete --app my-app --yes

The app delete command doesn’t delete integrations. To delete one, run aws amplifygen3 integration delete --name integration-name.

Next steps