Deploying Serverless App with Next.js 8, AWS Lambda and CircleCI — Part 2

Deploying a serverless Next.js app using serverless framework, serverless-nextjs-plugin, and AWS Lambda function.

Manato Kuroda
4 min readJul 26, 2019



In part one of this article, we deploy a Next.js app using the Serverless framework and AWS lambda.

In part two, I will show you how to set up automatic deployments working with CircleCI 2.1.

Example repo

Most of what you will read below in this part is covered in a sample repository.


If you haven’t read part one, follow the instructions and set it up for deployment. This article assumes a few basic ideas of CircleCI in order to illustrate how it can work smoothly. If you haven’t signed up yet, check it out so it’ll help you get started.

Getting started

Follow the steps to deployments:

  • Add deploy scripts to package.json
  • Add Node job to the configuration
  • Add Deploy job to the configuration

Add deploy scripts to package.json

In part one, you have two environments, staging and production in your app and hit the Serverless command every time deploying like this:

$ sls deploy -v --stage staging // for staing
$ sls deploy -v --stage production // for production

It’s totally okay but could be improved adding scripts in package.json:

/* package.json */{
"name": "my-app",
"scripts": {
"dev": "next",
"build": "next build"…