8

I am looking for some advices, I am using Next.js to serve static pages that can be updated frequently, my app uses all kind of rendering : SSG, SSR and iSSG (new Incremental Static Site Generation feature).

Exemple of AWS architecture I thought:

  • EC2 to deploy a node.js server running next.js app
  • (if it is possible) Store/update static pages generated by Next.js SSR/iSSG in a S3 bucket
  • Cloudfront to cache pages (using either EC2 or S3 bucket if it is possible)

Do you know what is the best AWS architecture I could use according to my needs?

Edit: Maybe AWS Elastic Beanstalk is the solution, I am taking a look.

Alex Coding
  • 81
  • 1
  • 3
  • Did you found anything? I am thinking to use ECS fargate with EFS to store the build directory at common location. – Rishikesh Darandale Sep 05 '20 at 08:54
  • you can use serverless nextjs https://github.com/serverless-nextjs/serverless-next.js It deploys on CloudFront and creates lambda function and uses s3 for storage – kartikag01 Sep 20 '20 at 18:00
  • You can look into AWS Amplify. It may require additional code modification but this can result in easier deployments. – Atakan Atamert Aug 30 '21 at 19:00

1 Answers1

1

Next.js 11 + SST + Lambda@Edge

Serverless deployment was introduced in Next.js 8. This makes it easier for you to deploy your Next.js app to AWS Lambda functions, and take advantage of the serverless architecture. It's often much cheaper to host this way, and faster because you are serving the pages behind a CloudFront CDN network.

The SST framework makes it easy to help build and deploy your Next.js app to your AWS account using a combination of S3, Lambda@Edge and CloudFront. It also helps you configure a custom domain for the endpoint.

Here's an example walking through the setup - https://serverless-stack.com/examples/how-to-create-a-nextjs-app-with-serverless.html

Frank
  • 670
  • 8
  • 12