#Next.js app that is exported as standalone output
1 messages · Page 1 of 1 (latest)
Yes, a Next.js app can be exported as a standalone output and support Server-Side Rendering (SSR). This is achieved by enabling the output as 'standalone' in your next.config.js file. Here's how you can do it:
module.exports = {
output: 'standalone',
}
This will create a folder at .next/standalone which can then be deployed on its own without installing node_modules. A minimal server.js file is also output which can be used instead of next start. This minimal server does not copy the public or .next/static folders by default as these should ideally be handled by a CDN instead. However, these folders can be copied to the standalone/public and standalone/.next/static folders manually, after which server.js file will serve these automatically[^1^].
If your project uses Image Optimization with the default loader, you must install sharp as a dependency[^1^].
As for deploying on AWS, while the sources do not provide specific instructions for AWS, they do mention that Next.js supports static export and can be deployed and hosted on any web server that can serve HTML/CSS/JS static assets[^2^][^3^]. This includes tools like AWS S3[^2^][^3^].
For scaling, you might want to consider using a serverless architecture, which AWS supports. Serverless architectures can automatically scale to meet traffic demands, which is ideal for web applications.
[^1^]: (source: https://nextjs.org/docs/app/api-reference/next-config-js/output#automatically-copying-traced-files)
[^2^]: (source: https://nextjs.org/docs/app/building-your-application/deploying/static-exports)
[^3^]: (source: https://nextjs.org/docs/pages/building-your-application/deploying/static-exports)
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@lean glacier kapa.ai is still learning and improving, please let us know how it did by reacting below