Is it possible to deploy Nuxt SSR application on AWS?

Viewed 7106

I'm new to AWS. I can't find any explanation on how to deploy Nuxt SSR app on AWS although I could find ones on how to deploy static Nuxt app there. Is it possible to deploy Nuxt SSR app on AWS? I have spent long enough time already so please let me ask for your help. Thanks.

3 Answers

Yes, you can deploy just about anything on AWS if you configure the compute resources correctly. Static websites can be served from S3 directly, but for those with a dynamic backend you'll need to use something like EC2 or Lambda. I found this guide for using Lambda and Serverless Framework to deploy a Nuxt SSR app: https://dzone.com/articles/a-crash-course-on-serverless-side-rendering-with-v

You could also use an EC2 instance as your compute engine, but to do that you'll need to install all the dependencies and manage the host operating system and the web server. Hope that helps!

When it comes to AWS there are usually a few ways to skin a cat. I have however deployed a containerised SSR NUXT application with AWS CloudFront and AWS Fargate/ECS using AWS Copilot. AWS Amplify is great for static deployment.

If you are actually running the NUXT application in ssr: true (this is the default configuration) and/or target: 'server', then you can't deploy it in the same way that you would deploy your usual 'static' web application (e.g. S3 hosting with AWS won't work with an SSR application). So if you run 'nuxt build' to build the application you will see a (hidden) .nuxt/ directory will be generated in your application directory. If you run 'nuxt generate' however, you will see a /dist folder in your application directory that isn't hidden. In the latter case, you are most likely not leveraging NUXT's SSR capabilities (check your ssr and target properties in your nuxt.config.js file to see if it is 'universal' and/or 'server' respectively, see docs on ssr here and target here) and could deploy to AWS S3 with CloudFront or with AWS Amplify.

In the case you are using SSR, then this tutorial from AWS is will help you to deploy a containerised version of your app to AWS ECS.

UPDATE: I spoke to AWS this week who advised that AWS Amplify now supports container deployment, so you could dockerise the application and deploy it there quite easily.

There is a service particularly made for this now called Fume https://fume.app

Related