Member-only story
Next.js9 + serverless component set up for AWS codebuild and cloudfront deployment
Have you ever wished that you could use awesome Next.js ssr(server side rendering) feature without having a server spainning? Have you having trouble map the nextjs route using static export? In this article, I’ll introduce you the latest and easiest way to deploy Next.js 9 applications with serverless-nextjs plugin.
What you’ll need
First, make sure you have latest Nextjs in your package.json in order to use serverless-next.js component. The version I am using now is 9.1.2. The serverless-next.js plugin is using serverless component to manage and deploy your nextjs code directly to a S3 bucket and create cloudfront distribution for you. The beautiful thing is that serverless-next.js will only require few lines of config and it will work the rest for you as simple as this:
Second, make sure you store your .serverless folder in a S3 bucket if you have tried deploy it locally and wish to use the same url it created for you on the cloudfront. Currently, as in Nov 2019, there is still a…