I'm curious if it's possible to deploy a Next.js app on AWS and achieve similar benefits to what Vercel provides, such as CDN-level caching, on-the-fly image optimization, and minimal cold starts. I've started to explore AWS and am considering hosting my application there instead of Vercel. I'm particularly interested in: 1) Is it feasible to self-host a Next.js app on AWS while maintaining good performance? 2) What AWS services and configurations will I need? 3) What features might I lose or have to replicate manually from Vercel? 4) How can I efficiently host server-rendered pages on AWS using options like Lambda, App Runner, or EC2? I'm not avoiding Vercel due to any specific issues; I just want to see if I can recreate a similar setup with AWS tools. Thanks for any insights!
4 Answers
For static single-page applications, S3 combined with CloudFront works well, but I'm not so sure about server-side rendering with that setup.
You could also try Elastic Beanstalk or Amplify, but I wouldn't recommend going with EC2 unless you're comfortable managing the security of the operating system yourself. It's worth considering your level of expertise with AWS.
Absolutely, you can use AWS Amplify Hosting for Next.js, and it handles SSR with the WEB_COMPUTE option. It’s straightforward to set up and you can find more details in their documentation!
Check out SST (sst.dev). It allows for easy self-deployment on AWS with serverless or containerized apps, and they created Opennext to simplify deploying Next.js outside of Vercel. Just keep in mind that while AWS Amplify offers convenience, you may miss out on using AWS's Always Free Tier efficiently for services like CloudFront and Lambda.
Can S3 handle npm packages though?