Cloud
DevOps

How to Deploy a Node.js and React App to AWS (2026 Guide)

How to Deploy Node.js React App to AWS: Strategies and Best Practices

The most common way to deploy a Node.js and React app to AWS in 2026 is to host the React build as static files on Amazon S3 behind CloudFront, and run the Node.js API in containers on Amazon ECS with Fargate. For smaller apps, AWS Amplify Hosting or AWS Lambda behind API Gateway are simpler options. The right choice depends on traffic patterns, team skills and how much control you need.

Deploying Node.js and React solutions on AWS is one of the most common tasks in our practice. Node.js runs the backend (often with Express and a database such as MongoDB), while React builds the user interface. This guide compares the main deployment options, shows a recommended production setup with working commands, and lists the practices that keep it secure and affordable. It was fully updated for 2026.

Which AWS Deployment Options Can You Use for Node.js and React?

AWS offers several ways to run the same application. The table below compares them by what they suit best, how much work they take and how you pay.

OptionBest forComplexityCost model
S3 + CloudFront (React only)Any React single-page app; the standard frontend setupLowStorage and data transfer; CloudFront includes a free monthly allowance
Amazon ECS on FargateProduction Node.js APIs, microservices, steady trafficMediumPer vCPU and GB of memory per second while tasks run
AWS App RunnerSmall teams wanting containers without managing clustersLowPer vCPU and memory, with a lower rate for idle provisioned instances
AWS Lambda + API GatewaySpiky or low traffic, event-driven APIsMediumPer request and compute time; generous free tier
AWS Amplify Hosting (Gen 2)MVPs, full-stack TypeScript teams, fast CI/CDLowBuild minutes, hosting and data transfer
Amazon EKSTeams already standardised on Kubernetes, many servicesHighCluster fee plus nodes or Fargate
Amazon EC2 / Elastic BeanstalkLegacy apps, custom OS needs, full controlMedium to highInstances running 24/7, whether busy or not

If you are unsure, start with S3 + CloudFront for React and ECS Fargate or App Runner for the API. You can move parts to Lambda later where traffic is spiky. If you are moving an existing system rather than starting fresh, our guide to AWS migration consultants explains when outside help pays off.

Recommended Setup: React on S3 and CloudFront, Node.js on ECS Fargate

This is the setup we deploy most often for production workloads. It separates the static frontend from the API, scales each independently and avoids managing servers.

Step 1. Deploy the React frontend to S3 and CloudFront

Build the app, upload the files to a private S3 bucket and serve them through a CloudFront distribution with Origin Access Control, so the bucket is never public. After each release, invalidate the CloudFront cache:

npm run build   # Vite outputs to dist/, Create React App to build/
aws s3 sync dist/ s3://my-app-frontend --delete
aws cloudfront create-invalidation --distribution-id E123EXAMPLE --paths "/*"

For client-side routing, configure CloudFront to return index.html for 403 and 404 responses so deep links work.

Step 2. Containerize the Node.js API

A small, production-only image keeps deployments fast and reduces the attack surface. If containerization is new to your team, this Dockerfile is a good starting point:

FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
ENV NODE_ENV=production
EXPOSE 3000
USER node
CMD ["node", "server.js"]

Step 3. Push the image to Amazon ECR

aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.eu-central-1.amazonaws.com
docker build -t my-api .
docker tag my-api:latest 123456789012.dkr.ecr.eu-central-1.amazonaws.com/my-api:latest
docker push 123456789012.dkr.ecr.eu-central-1.amazonaws.com/my-api:latest

Step 4. Run it on ECS Fargate with infrastructure as code

Rather than clicking through the console, define the service in code. With the AWS CDK you can write it in TypeScript, the same language as your app. This creates a load-balanced Fargate service with two tasks:

import * as cdk from 'aws-cdk-lib';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as ecsPatterns from 'aws-cdk-lib/aws-ecs-patterns';

const app = new cdk.App();
const stack = new cdk.Stack(app, 'ApiStack');

new ecsPatterns.ApplicationLoadBalancedFargateService(stack, 'Api', {
  cpu: 512,
  memoryLimitMiB: 1024,
  desiredCount: 2,
  taskImageOptions: {
    image: ecs.ContainerImage.fromAsset('./api'),
    containerPort: 3000,
  },
  publicLoadBalancer: true,
});

Run cdk deploy and CDK builds the image, pushes it and provisions the VPC, cluster, load balancer and service. Add auto scaling on CPU or request count once you know your traffic. See how we did this for a client in our case study on deploying a Node.js and React app to AWS with ECS.

Other Ways to Deploy Node.js and React on AWS

Serverless with AWS Lambda and API Gateway

With AWS Lambda you deploy the API as functions and pay only for requests and compute time. It suits APIs with uneven or low traffic and event-driven work such as file processing or webhooks.

  • Pros: no servers to manage, automatic scaling, cost close to zero at low traffic.
  • Cons: 15-minute maximum run time per invocation, cold starts on infrequently used functions, and long-lived connections (WebSockets, database pools) need extra design.

AWS Amplify Hosting (Gen 2)

AWS Amplify connects to your Git repository, builds the app on every push and hosts it with a managed CDN. Amplify Gen 2 lets you define backend resources such as authentication, data and functions in TypeScript alongside the app.

  • Pros: fastest path to a live app, built-in CI/CD and preview environments.
  • Cons: less control over the build and runtime; complex architectures often outgrow it.

AWS App Runner

App Runner takes a container image or source repository and runs it as a web service with automatic scaling and HTTPS, without clusters or load balancers to configure. It is a good fit for a single Node.js API run by a small team.

Amazon EKS

If your organisation already runs Kubernetes, EKS gives you the same tooling on AWS. For one Node.js app it is usually more than you need; it pays off when you run many microservices with shared platform tooling.

EC2 virtual machines and Elastic Beanstalk

Running Node.js on EC2 gives full control of the operating system, which some legacy apps need. Elastic Beanstalk automates part of the setup. The trade-off is that you patch, scale and monitor the instances yourself, and you pay for them 24/7 whether they are busy or not.

Best Practices for Node.js and React Deployments on AWS

  • Automate releases. Use CI/CD pipelines (GitHub Actions, GitLab CI or AWS CodePipeline) so every deployment is repeatable and can be rolled back.
  • Define infrastructure as code. Use AWS CDK, Terraform or CloudFormation instead of manual console changes.
  • Use IAM roles, not access keys. Give tasks and functions only the permissions they need, and keep secrets in AWS Secrets Manager or SSM Parameter Store.
  • Serve everything over HTTPS. Use AWS Certificate Manager certificates on CloudFront and the load balancer.
  • Monitor from day one. Send logs and metrics to CloudWatch, add alarms on error rates and latency, and trace requests with AWS X-Ray or OpenTelemetry.
  • Watch costs. Tag resources per environment, right-size Fargate tasks and review data transfer charges; our AWS cost optimization guide covers the main levers.

Frequently Asked Questions

Can I host a React app on AWS for free?

Small React apps can often run within the AWS Free Tier using S3 and CloudFront, which includes a monthly allowance of data transfer. Costs grow with traffic and storage.

Should I use ECS or EKS for a Node.js API?

Choose ECS with Fargate if you want the simplest managed container platform. Choose EKS if your team already uses Kubernetes or you need its ecosystem across many services.

Is AWS Lambda good for a Node.js backend?

Yes, for APIs with uneven traffic and short requests. For constant high traffic, long-running jobs or WebSockets, containers on Fargate are usually cheaper and simpler.

Should the React frontend and Node.js backend be deployed together?

It is usually better to deploy them separately: the frontend as static files on S3 and CloudFront, the backend as a service. This lets you scale, cache and release each part independently.

How long does it take to deploy a Node.js and React app to AWS?

A basic setup with Amplify or App Runner can be live in a day. A production setup with infrastructure as code, CI/CD, monitoring and security reviews typically takes one to three weeks.

Conclusion

For most teams, the best way to deploy a Node.js and React app to AWS is static hosting on S3 and CloudFront for the frontend and containers on ECS Fargate for the API, managed with infrastructure as code and a CI/CD pipeline. Lambda, Amplify and App Runner are good alternatives when simplicity or pay-per-use pricing matters more than control.

Need help deploying or migrating a Node.js and React application? Our AWS DevOps services team has delivered these setups for SaaS products and startups, and you can also hire AWS developers to extend your own team.

FAQ

Why deploy a Node.js React app to AWS?

AWS provides scalable infrastructure and a variety of services that can host and manage Node.js and React applications effectively. It offers flexibility, reliability, and scalability, making it a popular choice for deploying web applications.

What services are commonly used to deploy Node.js React apps on AWS?

Commonly used services include: Amazon Elastic Compute Cloud (EC2) for virtual server hosting. AWS Elastic Beanstalk for simplified deployment and management of applications. AWS Lambda for serverless computing. Amazon S3 for static file hosting. Amazon CloudFront for content delivery network (CDN) services.

How can I deploy a Node.js React app on AWS?

There are several approaches: Manual Deployment: This involves setting up EC2 instances, configuring them, and deploying your app manually. Automated Deployment: Use AWS Elastic Beanstalk or AWS CodeDeploy for automated deployment and management. Serverless Deployment: Utilize AWS Lambda and API Gateway to deploy serverless applications.

What are the steps for manual deployment on AWS?

Provision an EC2 instance. Install Node.js, npm, and other necessary dependencies. Clone your Node.js React app repository onto the instance. Build the React app. Configure the server to serve the built React app. Set up a reverse proxy (e.g., using Nginx or Apache). Configure security groups and firewall settings. Point your domain to the EC2 instance's IP address.

How do I set up automated deployment using Elastic Beanstalk?

Package your Node.js React app into a .zip or .tar.gz file. Create an Elastic Beanstalk application and environment. Upload your application package. Configure environment settings such as instance type, security groups, and scaling options. Elastic Beanstalk will handle deployment, load balancing, and scaling automatically.

Is serverless deployment a viable option for Node.js React apps on AWS?

Yes, serverless deployment using AWS Lambda and API Gateway can be a cost-effective and scalable option for certain applications, especially those with variable traffic patterns.

How can I ensure security when deploying a React app on AWS?

Utilize AWS IAM roles for security, implement HTTPS, and follow AWS security best practices. Additionally, consider implementing CI/CD pipelines for automated security checks.

What are the benefits of using Docker for deploying React apps on AWS?

Docker offers isolation, easy scalability, and flexibility. It simplifies dependency management and allows for consistent deployment across different environments.

How can I choose the right deployment method for my React app on AWS?

Consider factors such as scalability, flexibility, complexity, and project requirements. Evaluate each deployment method's pros and cons to determine the best fit for your specific use case.
arrow arrow

Thank you
for contacting us!

Please, check your email

arrow arrow

Thank you

You've been subscribed

We use cookies to enhance your browsing experience. By clicking "Accept," you consent to the use of cookies. To learn more, read our Privacy Policy