Deploy a React app on AWS
Deployment.io builds your React app from its repository and serves it from Amazon S3 and CloudFront in your own AWS account.
Before you start
- The app is in a GitHub, GitLab or Bitbucket repository that's connected to Deployment.io. See Adding a Repository.
- The app is built with Vite or Create React App.
Deployment
- Create a new Static site on Deployment.io.
- Select your app's repository.
- Build command:
npm run build. - Publish directory:
dist(Vite) orbuild(Create React App). - Single-page app: Yes.
- Root directory: leave it empty unless the app lives in a subfolder of the repository (a monorepo). Then enter that folder.
- Choose the Environment and click Deploy static site.
Your site is available at the CloudFront URL shown in the dashboard once the build finishes. See Adding Custom Domains and Automatic Deployment on Git Push.
How the build runs
Deployment.io installs the app's dependencies before the build command, with the package manager its lockfile names — npm (package-lock.json), Yarn (yarn.lock) or pnpm (pnpm-lock.yaml). A packageManager field in package.json is honoured. So the build command is only the build itself — don't add an install step.
Builds run on Node.js 22, and package.json must be at the top of the repository or of the Root directory.
Environment variables
The environment's variables are available to the build. Vite puts only variables with the VITE_ prefix into the code that runs in the browser; Create React App puts only those with the REACT_APP_ prefix.
Anything in a static site's build is public — never put a secret there.
Routing
Client-side routing (for example React Router) works: any address without a file of its own serves index.html, and the router takes over.