serverless icon indicating copy to clipboard operation
serverless copied to clipboard

[Discussion] Next.js application pattern

Open andrewgadziksonos opened this issue 4 years ago • 3 comments

Hello and greetings from Sonos!

First off, I just wanted to say thank you for supplying an amazing repo of patterns. This has inspired us to start tackling one of our more challenging deployments and hopefully convert it to something anyone can use.

I wanted to chat about application frameworks like Next.JS. These frameworks provide end-to-end application development experience that makes it very appealing to development teams. The only issue is that they want you to spend money on their hosting platform versus providing any guidance on how to host yourself.

https://nextjs.org/docs/deployment

Their basic solution for you is to spin up an EC2 and run the start script. I'm sure we could also explore using ECR/ECS with containers but where's the fun in that. We want a serverless solution!

The Serverless community has built a somewhat working solution here https://serverless-nextjs.com/ but its definitely lacking Next.JS features and I'm not 💯 sure about their approach. CloudFront + Lambda@edge used for APIs, etc.

The Terraform community has built another solution here https://registry.terraform.io/modules/dealmore/next-js/aws/latest and is also lacking some core NextJS features and appears to still be in active development. I do like their approach to the serverless architecture here. It just feels better and isn't forced like the Serverless approach is.

I was hoping this community could band together and vet each solution to come up with a proper pattern for these types of application frameworks 🤞

Cheers,

Andrew

andrewgadziksonos avatar Dec 16 '20 14:12 andrewgadziksonos

This could be an option - https://github.com/dabit3/next.js-cdk-amplify-workshop

cdk-patterns avatar Dec 19 '20 06:12 cdk-patterns

This could be an option - https://github.com/dabit3/next.js-cdk-amplify-workshop

Aye, I've looked into these sort of patterns in the past and I want to like Amplify. It still doesn't support backend routes from NextJS (think SSR routes, or dynamic routes). It still relies on Serverless to deploy the entire NextJS app out to Cloudfront. https://github.com/dabit3/next.js-cdk-amplify-workshop#deployment-with-serverless-framework.

I'll start creating some diagrams next week to start the conversation. I think we can combine a few of the patterns laid out here into a best practice NextJS pattern.

andrewgadziksonos avatar Dec 19 '20 14:12 andrewgadziksonos

Yes, I agree that the full SSR deployment on AWS is complicated, that is, not only on AWS, but the SSR architecture is a complicated thing.

Months ago I did a lab and deployed a small SSR solution (NuxtJS) using Lambda @ Edge + Cloudfront and it works well.

Count on me to discuss this and try to create a pattern for it using the CDK.

leandrodamascena avatar Dec 19 '20 14:12 leandrodamascena